diff --git a/dist/index.js b/dist/index.js index 24b1876..c3fe9a5 100644 --- a/dist/index.js +++ b/dist/index.js @@ -52198,6 +52198,7 @@ const path = __importStar(__nccwpck_require__(16928)); const semver = __importStar(__nccwpck_require__(62088)); const promises_1 = __nccwpck_require__(16460); const logging_1 = __nccwpck_require__(91338); +const tailscaledLogPath = path.join(os.homedir(), "tailscaled.log"); const cmdTailscale = "tailscale"; const cmdTailscaleFullPath = "/usr/local/bin/tailscale"; const cmdTailscaled = "tailscaled"; @@ -52695,11 +52696,7 @@ async function startTailscaleDaemon(config) { // Start daemon in background const daemon = (0, child_process_1.spawn)("sudo", ["-E", cmdTailscaled, ...args], { detached: true, - stdio: [ - "ignore", - "ignore", - fs.openSync(path.join(os.homedir(), "tailscaled.log"), "w"), - ], + stdio: ["ignore", "ignore", fs.openSync(tailscaledLogPath, "w")], }); // Store PID for cleaning up daemon process in logout.ts. const pidFile = path.join(xdgRuntimeDir(), "tailscaled.pid"); @@ -52740,7 +52737,31 @@ async function waitForDaemonReady(logMode) { await sleep(pollIntervalMs); waited += pollIntervalMs; } - throw new Error(`tailscaled daemon did not become ready within timeout, last error: ${lastErr}`); + throw new Error(`tailscaled daemon did not become ready within timeout, last error: ${lastErr}${tailscaledLogHint()}`); +} +// tailscaledLogHint returns the end of tailscaled's log when debug logging +// is enabled, and otherwise a note on how to get it. +function tailscaledLogHint(maxLines = 20) { + if (!core.isDebug()) { + return "\nRe-run with debug logging enabled to include the tailscaled log in this error."; + } + try { + const lines = fs + .readFileSync(tailscaledLogPath, "utf8") + .split("\n") + .filter((line) => line.trim() !== ""); + if (lines.length === 0) + return ""; + // tailscaled logs proxy URLs, which can carry credentials. + const tail = lines + .slice(-maxLines) + .join("\n") + .replace(/(\w+:\/\/)[^\/\s@]+@/g, "$1REDACTED@"); + return `\ntailscaled log (last ${Math.min(lines.length, maxLines)} lines of ${tailscaledLogPath}):\n${tail}`; + } + catch { + return ""; + } } async function connectToTailscale(config, runnerOS) { // Determine hostname diff --git a/src/main.ts b/src/main.ts index 73fb892..66232fd 100644 --- a/src/main.ts +++ b/src/main.ts @@ -22,6 +22,7 @@ import { } from "./logging"; import type { LogMode } from "./logging"; +const tailscaledLogPath = path.join(os.homedir(), "tailscaled.log"); const cmdTailscale = "tailscale"; const cmdTailscaleFullPath = "/usr/local/bin/tailscale"; const cmdTailscaled = "tailscaled"; @@ -770,11 +771,7 @@ async function startTailscaleDaemon(config: TailscaleConfig): Promise { // Start daemon in background const daemon = spawn("sudo", ["-E", cmdTailscaled, ...args], { detached: true, - stdio: [ - "ignore", - "ignore", - fs.openSync(path.join(os.homedir(), "tailscaled.log"), "w"), - ], + stdio: ["ignore", "ignore", fs.openSync(tailscaledLogPath, "w")], }); // Store PID for cleaning up daemon process in logout.ts. @@ -824,10 +821,33 @@ async function waitForDaemonReady(logMode: LogMode): Promise { } throw new Error( - `tailscaled daemon did not become ready within timeout, last error: ${lastErr}`, + `tailscaled daemon did not become ready within timeout, last error: ${lastErr}${tailscaledLogHint()}`, ); } +// tailscaledLogHint returns the end of tailscaled's log when debug logging +// is enabled, and otherwise a note on how to get it. +function tailscaledLogHint(maxLines = 20): string { + if (!core.isDebug()) { + return "\nRe-run with debug logging enabled to include the tailscaled log in this error."; + } + try { + const lines = fs + .readFileSync(tailscaledLogPath, "utf8") + .split("\n") + .filter((line) => line.trim() !== ""); + if (lines.length === 0) return ""; + // tailscaled logs proxy URLs, which can carry credentials. + const tail = lines + .slice(-maxLines) + .join("\n") + .replace(/(\w+:\/\/)[^\/\s@]+@/g, "$1REDACTED@"); + return `\ntailscaled log (last ${Math.min(lines.length, maxLines)} lines of ${tailscaledLogPath}):\n${tail}`; + } catch { + return ""; + } +} + async function connectToTailscale( config: TailscaleConfig, runnerOS: string,