Skip to content

Commit 52aa03f

Browse files
committed
stop echoing tailscale status to console
Updates #201 Signed-off-by: Percy Wegmann <percy@tailscale.com>
1 parent 2976a88 commit 52aa03f

File tree

4 files changed

+51
-27
lines changed

4 files changed

+51
-27
lines changed

dist/index.js

Lines changed: 15 additions & 6 deletions
Large diffs are not rendered by default.

package-lock.json

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"license": "BSD-3-Clause",
1515
"dependencies": {
1616
"@actions/cache": "^4.0.0",
17-
"@actions/core": "^1.10.1",
17+
"@actions/core": "^1.10.1",
1818
"@actions/exec": "^1.1.1",
1919
"@actions/github": "^6.0.1",
2020
"@actions/tool-cache": "^2.0.1"
@@ -30,4 +30,4 @@
3030
"glob": "^10.3.10",
3131
"inflight": "npm:@isaacs/inflight@^1.0.6"
3232
}
33-
}
33+
}

src/main.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,21 @@ type tailscaleStatus = {
5858

5959
// Cross-platform Tailscale local API status check
6060
async function getTailscaleStatus(): Promise<tailscaleStatus> {
61-
const { stdout } = await exec.getExecOutput(cmdTailscale, [
62-
"status",
63-
"--json",
64-
]);
61+
const { exitCode, stdout, stderr } = await exec.getExecOutput(
62+
cmdTailscale,
63+
["status", "--json"],
64+
{
65+
silent: true,
66+
ignoreReturnCode: true,
67+
}
68+
);
69+
if (exitCode !== 0) {
70+
process.stderr.write(stderr);
71+
throw new Error(`tailscale status failed with exit code ${exitCode}`);
72+
}
73+
if (core.isDebug()) {
74+
process.stdout.write(stdout);
75+
}
6576
return JSON.parse(stdout);
6677
}
6778

@@ -574,6 +585,7 @@ async function waitForDaemonReady(): Promise<void> {
574585

575586
core.info("Waiting for tailscaled daemon to become ready...");
576587

588+
var lastErr: any;
577589
while (waited < maxWaitMs) {
578590
try {
579591
const status = await getTailscaleStatus();
@@ -586,13 +598,16 @@ async function waitForDaemonReady(): Promise<void> {
586598
}
587599
} catch (err) {
588600
// Daemon not ready yet, keep polling
601+
lastErr = err;
589602
core.debug(`Waiting for daemon... (${waited}ms elapsed)`);
590603
}
591604
await sleep(pollIntervalMs);
592605
waited += pollIntervalMs;
593606
}
594607

595-
throw new Error("tailscaled daemon did not become ready within timeout");
608+
throw new Error(
609+
`tailscaled daemon did not become ready within timeout, last error: ${lastErr}`
610+
);
596611
}
597612

598613
async function connectToTailscale(

0 commit comments

Comments
 (0)