Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): stop agent jobs that escape the CLI's process group on macOS and Windows #33691

Closedc-ehrlich(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/33691/headopened View on GitHub

Showing 6 changed files with 96 additions and 0 deletions (loading 3).

x
0 of 6 viewed, 6 left
4 additions and 0 deletionsapps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.tsModified
View file
@@ -1250,6 +1250,7 @@
child.stderr
.setEncoding("utf8")
.on("data", (chunk: string) => options.stderr?.(chunk));
+ if (stopScope !== undefined) child.once("exit", stopScope);
return child;
let spawnedProcess: ClaudeSpawnedProcess | undefined;
@@ -1258,6 +1259,9 @@
const spawnClaudeCodeProcess = (spawnOptions: ClaudeSpawnOptions) => {
const child = spawnProcess(spawnOptions);
spawnedProcess = child;
+ if (unit !== undefined && "pid" in child && typeof child.pid === "number") {
+ runFork(agentScope.adopt(unit, child.pid));
+ }
// A spawn that fails emits only "error".
const releaseAgent = portDiscovery.trackAgent();
child.once("exit", releaseAgent);
89 additions and 0 deletionsapps/server/src/orchestration-v2/Adapters/ClaudeAgentSdkQueryRunner.test.tsModified
View file
@@ -26,7 +26,10 @@
import { ProviderEventLoggers } from "@t3tools/provider-core/server/ProviderEventLoggers";
import { makeProviderFailure } from "@t3tools/provider-core/server/failure";
import { signalProcessGroup } from "@t3tools/provider-core/server/processGroup";
+import * as ServerConfig from "../../config.ts";
import * as PortScanner from "../../preview/PortScanner.ts";
+import * as TrackedAgentScope from "../../process/trackedAgentScope.ts";