Skip to content

Commit 3241936

Browse files
fix: clear Tailscale probe timeout
The checkBinary helper used Promise.race with a setTimeout-based timeout but never cleared the timer when runExec completed first. Wrap the race in a try/finally that clears the timer handle to avoid a dangling timer.
1 parent 8b14321 commit 3241936

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

src/infra/tailscale.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,17 @@ export async function findTailscaleBinary(): Promise<string | null> {
4040
}
4141
try {
4242
// Use Promise.race with runExec to implement timeout
43-
await Promise.race([
44-
runExec(path, ["--version"], { timeoutMs: 3000 }),
45-
new Promise<never>((_, reject) => {
46-
setTimeout(() => reject(new Error("timeout")), 3000);
47-
}),
48-
]);
43+
let timer: ReturnType<typeof setTimeout> | undefined;
44+
try {
45+
await Promise.race([
46+
runExec(path, ["--version"], { timeoutMs: 3000 }),
47+
new Promise<never>((_, reject) => {
48+
timer = setTimeout(() => reject(new Error("timeout")), 3000);
49+
}),
50+
]);
51+
} finally {
52+
if (timer) clearTimeout(timer);
53+
}
4954
return true;
5055
} catch {
5156
return false;

0 commit comments

Comments
 (0)