Skip to content

Commit fc76a2f

Browse files
committed
stop echoing tailscale status to console
Updates #201 Signed-off-by: Percy Wegmann <[email protected]>
1 parent 2976a88 commit fc76a2f

File tree

4 files changed

+53
-27
lines changed

4 files changed

+53
-27
lines changed

dist/index.js

Lines changed: 16 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: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,22 @@ 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+
}
76+
core.debug(stdout);
6577
return JSON.parse(stdout);
6678
}
6779

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

575587
core.info("Waiting for tailscaled daemon to become ready...");
576588

589+
var lastErr: any;
577590
while (waited < maxWaitMs) {
578591
try {
579592
const status = await getTailscaleStatus();
@@ -586,13 +599,16 @@ async function waitForDaemonReady(): Promise<void> {
586599
}
587600
} catch (err) {
588601
// Daemon not ready yet, keep polling
602+
lastErr = err;
589603
core.debug(`Waiting for daemon... (${waited}ms elapsed)`);
590604
}
591605
await sleep(pollIntervalMs);
592606
waited += pollIntervalMs;
593607
}
594608

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

598614
async function connectToTailscale(

0 commit comments

Comments
 (0)