@devries-cameron20 / t3code-1 / commits / f99b2835ef
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(provider-core): a timed-out status probe stops a CLI that ignores SIGTERM (#35379)

Julius Marminge committed Nov 12, 2026 at 09:02 UTC f99b2835ef0d18559a59dd954e9f564fcb43e7d3
2 files changed +33 -1
packages/provider-core/src/server/snapshotProbe.test.ts
+18
@@ -1,8 +1,10 @@
1 +import * as NodeServices from "@effect/platform-node/NodeServices";
2 import { describe, expect, it } from "@effect/vitest";
3 import type { ModelCapabilities } from "@t3tools/contracts";
4 import * as HostProcess from "@t3tools/shared/HostProcess";
5 import { createModelCapabilities } from "@t3tools/shared/model";
6 import * as Effect from "effect/Effect";
7 +import * as Option from "effect/Option";
8 import * as Sink from "effect/Sink";
9 import * as Stream from "effect/Stream";
10 import * as ChildProcess from "effect/process/ChildProcess";
@@ -158,3 +160,19 @@ describe("ProviderCommandNotFoundError", () => {
160 });
161 });
162 });
163 +
164 +describe("spawnAndCollect", () => {
165 + // regression: #35262 - without forceKillAfter a timed-out probe whose CLI ignores
166 + // SIGTERM waits for it to exit, so the caller's timeout never returns.
167 + it.live.skipIf(HostProcess.Platform.defaultValue() === "win32")(
168 + "lets a timed-out probe return when the CLI ignores SIGTERM",
169 + () =>
170 + Effect.gen(function* () {
171 + const result = yield* spawnAndCollect(
172 + "sh",
173 + ChildProcess.make("sh", ["-c", 'trap "" TERM; sleep 30']),
174 + ).pipe(Effect.timeoutOption("200 millis"));
175 + expect(Option.isNone(result)).toBe(true);
176 + }).pipe(Effect.provide(NodeServices.layer)),
177 + );
178 +});
packages/provider-core/src/server/snapshotProbe.ts
+15 -1
@@ -112,12 +112,26 @@ export function providerProbeEnvironment(environment: NodeJS.ProcessEnv): NodeJS
112 return { ...environment, MISE_OFFLINE: "1" };
113 }
114
115 +// A timed-out probe interrupts the child with SIGTERM and then waits for it to exit,
116 +// so a CLI that ignores SIGTERM would hold the caller's timeout open without this.
117 +const PROBE_FORCE_KILL_AFTER = "1 second";
118 +
119 +function withProbeForceKill(command: ChildProcess.Command): ChildProcess.Command {
120 + if (!ChildProcess.isStandardCommand(command) || command.options.forceKillAfter !== undefined) {
121 + return command;
122 + }
123 + return ChildProcess.make(command.command, command.args, {
124 + ...command.options,
125 + forceKillAfter: PROBE_FORCE_KILL_AFTER,
126 + });
127 +}
128 +
129 export const spawnAndCollect = Effect.fn("snapshotProbe.spawnAndCollect")(function* (
130 binaryPath: string,
131 command: ChildProcess.Command,
132 ) {
133 const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
120 - const child = yield* spawner.spawn(command);
134 + const child = yield* spawner.spawn(withProbeForceKill(command));
135 const [stdout, stderr, exitCode] = yield* Effect.all(
136 [
137 collectStreamAsString(child.stdout),