From a12faee9ccae69787fcf5ce3a4c7383b3c7bc050 Mon Sep 17 00:00:00 2001 From: Jeremy Schoemaker Date: Fri, 27 Nov 2026 23:02:40 -0600 Subject: [PATCH] action: point at the tailscaled log when the daemon fails to start tailscaled's stderr goes to ~/tailscaled.log, so when the daemon exits at startup the job only reports that the local socket is unreachable. The cause, such as a missing /dev/net/tun, stays in a file that goes away with the runner. When debug logging is enabled, append the last 20 lines of that log to the timeout error, with credentials in URLs redacted. Otherwise say that re-running with debug logging will include it. Updates #140 Signed-off-by: Jeremy Schoemaker --- dist/index.js | 33 +++++++++++++++++++++++++++------ src/main.ts | 32 ++++++++++++++++++++++++++------ 2 files changed, 53 insertions(+), 12 deletions(-) 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,