Skip to content

Commit 4396359

Browse files
thymikeeclaude
andcommitted
fix(record): stop an abandoned swiftc with SIGINT so its frontend jobs end too
swift-driver runs each swift-frontend job in its own process group. A SIGKILL or SIGTERM on a canceled validator compile left the frontend compiling with no parent; a live cold-cache abandon showed it. On SIGINT the driver stops its jobs, and SIGKILL still follows after a 2 s grace. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent d0d88de commit 4396359

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎packages/capture-kit/src/recording/swift-cache.test.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,10 @@ test('a canceled compile kills swiftc through its signal and leaves no temp outp
190190
cancel.abort();
191191

192192
await expect(compiled).rejects.toSatisfy(isRequestCanceledError);
193-
expect(mockRunCmd.mock.calls[0]![2]?.signal).toBe(cancel.signal);
193+
expect(mockRunCmd.mock.calls[0]![2]).toMatchObject({
194+
signal: cancel.signal,
195+
kill: { signal: 'SIGINT' },
196+
});
194197
expect(fs.readdirSync(path.join(tmpDir, 'swift-cache', 'bin'))).toEqual([]);
195198
});
196199

‎packages/capture-kit/src/recording/swift-cache.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ import {
1616

1717
const SWIFT_CACHE_VERSION = '2';
1818
const LOCK_RETRY_DELAY_MS = 25;
19+
// swift-driver runs each frontend job in its own process group. It stops them on SIGINT, but
20+
// SIGKILL or SIGTERM leaves them compiling with no parent.
21+
const SWIFTC_STOP = { signal: 'SIGINT', graceMs: 2_000 } as const;
1922
const RECORDING_SCRIPT_SUBDIRECTORY = 'apple/runner/AgentDeviceRunner/RecordingScripts';
2023

2124
/**
@@ -198,6 +201,7 @@ async function ensureSwiftExecutable(params: {
198201
await runCmd('xcrun', ['swiftc', ...params.sourcePaths, '-o', tempExecutablePath], {
199202
timeoutMs,
200203
signal: params.signal,
204+
kill: SWIFTC_STOP,
201205
env: buildSwiftToolEnv(params.host.env),
202206
});
203207
fs.renameSync(tempExecutablePath, params.executablePath);

0 commit comments

Comments
 (0)