Skip to content
TypeScript

fix(tailscale): escalate hung serve commands to SIGKILL (#28529)

Rishabh_t106e2d3aa9b0fac
diff --git a/packages/tailscale/src/tailscale.test.ts b/packages/tailscale/src/tailscale.test.ts
index d1b90208443..96f6e7721ed 100644
--- a/packages/tailscale/src/tailscale.test.ts
+++ b/packages/tailscale/src/tailscale.test.ts
@@ -338,7 +338,8 @@ describe("tailscale", () => {
return Effect.gen(function* () {
yield* readTailscaleStatus.pipe(Effect.provide(layer));
yield* readTailscaleSshEnabled.pipe(Effect.provide(layer));
- assert.deepEqual(killGraces, [500, 500]);
+ yield* ensureTailscaleServe({ localPort: 45_678 }).pipe(Effect.provide(layer));
+ assert.deepEqual(killGraces, [500, 500, 500]);
});
});
});
diff --git a/packages/tailscale/src/tailscale.ts b/packages/tailscale/src/tailscale.ts
index cb5748d21e7..4eb20f1150b 100644
--- a/packages/tailscale/src/tailscale.ts
+++ b/packages/tailscale/src/tailscale.ts
@@ -397,12 +397,14 @@ const runTailscaleCommand = Effect.fn("tailscale.runTailscaleCommand")(function*
};
const timeout = Duration.fromInputUnsafe(timeoutInput);
return yield* Effect.gen(function* () {
- const child = yield* spawner.spawn(ChildProcess.make(executable, args)).pipe(
- Effect.mapError((cause) => new TailscaleCommandSpawnError({ ...commandContext, cause })),
- Effect.catchDefect((cause) =>
- Effect.fail(new TailscaleCommandSpawnError({ ...commandContext, cause })),
- ),
- );
+ const child = yield* spawner
+ .spawn(ChildProcess.make(executable, args, { forceKillAfter: TAILSCALE_KILL_GRACE }))
+ .pipe(
+ Effect.mapError((cause) => new TailscaleCommandSpawnError({ ...commandContext, cause })),
+ Effect.catchDefect((cause) =>
+ Effect.fail(new TailscaleCommandSpawnError({ ...commandContext, cause })),
+ ),
+ );
const [stderr, exitCode] = yield* Effect.all(
[collectStderr(child.stderr), child.exitCode.pipe(Effect.map(Number))],
{ concurrency: "unbounded" },