The best way to control Claude Code, Codex and more from any computer or phone
fix(tailscale): a timed-out tailscale probe no longer outlives its call (#22900)
Co-authored-by: fixfon <12512757+fixfon@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Theo Browne committed
Oct 21, 2026 at 14:09 UTC
0d876e004aed0b5d6b5fe3bd65d7375d6c29b146
2 files changed
+37
-1
packages/tailscale/src/tailscale.test.ts
+26
@@ -1,4 +1,5 @@
1
import { assert, describe, it } from "@effect/vitest";
2
+import * as Duration from "effect/Duration";
3
import * as Effect from "effect/Effect";
4
import * as Layer from "effect/Layer";
5
import * as Sink from "effect/Sink";
@@ -219,4 +220,29 @@ describe("tailscale", () => {
220
assertCarriesNoSecret(error, "tskey-auth-secret-token-value");
221
});
222
});
223
+
224
+ // regression: #21609 - without forceKillAfter a timed-out probe only gets
225
+ // SIGTERM, so a group member that ignores it outlives the call.
226
+ it.effect("escalates timed-out probes to SIGKILL", () => {
227
+ const killGraces: Array<number | undefined> = [];
228
+ const layer = layerSpawner(
229
+ ChildProcessSpawner.make((command) => {
230
+ if (command._tag === "StandardCommand") {
231
+ const { forceKillAfter } = command.options;
232
+ killGraces.push(
233
+ forceKillAfter === undefined
234
+ ? undefined
235
+ : Duration.toMillis(Duration.fromInputUnsafe(forceKillAfter)),
236
+ );
237
+ }
238
+ return Effect.succeed(mockHandle({ stdout: "{}" }));
239
+ }),
240
+ );
241
+
242
+ return Effect.gen(function* () {
243
+ yield* readTailscaleStatus.pipe(Effect.provide(layer));
244
+ yield* readTailscaleSshEnabled.pipe(Effect.provide(layer));
245
+ assert.deepEqual(killGraces, [500, 500]);
246
+ });
247
+ });
248
});
packages/tailscale/src/tailscale.ts
+11
-1
@@ -15,6 +15,13 @@ export const DEFAULT_TAILSCALE_SERVE_PORT = 443;
15
* that follows the timeout also takes time (`taskkill` on Windows).
16
*/
17
const TAILSCALE_STATUS_TIMEOUT = Duration.millis(3_500);
18
+/**
19
+ * How long a probe killed on timeout gets to exit after SIGTERM before its
20
+ * process group is SIGKILLed. Without it the spawner never escalates, so a group
21
+ * member that ignores SIGTERM outlives the call. Short because the timeout error
22
+ * only surfaces once cleanup finishes, and a healthy `tailscale` exits at once.
23
+ */
24
+const TAILSCALE_KILL_GRACE = Duration.millis(500);
25
const TAILSCALE_SERVE_TIMEOUT = Duration.seconds(10);
26
const TAILSCALE_PROBE_TIMEOUT = Duration.millis(2_500);
27
@@ -226,8 +233,11 @@ const readTailscaleOutput = Effect.fn("tailscale.readTailscaleOutput")(function*
233
subcommand,
234
argumentCount: args.length,
235
};
236
+ const command = ChildProcess.make(executable, [...args], {
237
+ forceKillAfter: TAILSCALE_KILL_GRACE,
238
+ });
239
return yield* Effect.gen(function* () {
230
- const child = yield* spawner.spawn(ChildProcess.make(executable, [...args])).pipe(
240
+ const child = yield* spawner.spawn(command).pipe(
241
Effect.mapError((cause) => new TailscaleCommandSpawnError({ ...commandContext, cause })),
242
// Spawning can also fail as a defect rather than a typed error - a
243
// non-directory entry on PATH makes node throw ENOTDIR synchronously.