Skip to content

Commit 27b3bb8

Browse files
sahrizviclaude
andcommitted
fix: escalate to SIGKILL in pty-tui dispose to avoid orphaned test children
The PTY test fixture's `dispose()` sent `SIGTERM` then waited up to 1000ms for exit, but never escalated. A child that traps/ignores `SIGTERM` (or is slow to tear down its render loop + worker) would be left orphaned when `dispose()` returns — a silent test-process leak on CI. Add a `SIGKILL` escalation after the grace window. The happy path (child exits cleanly within the grace) is byte-for-byte unchanged. Addresses the OpenCodeReview finding on `packages/opencode/test/fixture/pty-tui.ts`. Verified: typecheck clean; `phase-label.tui-e2e.test.ts` passes (fixture launches + disposes cleanly). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_012WRxuYemV9xjUArbumGSUC
1 parent 9b88a7f commit 27b3bb8

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

‎packages/opencode/test/fixture/pty-tui.ts‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,22 @@ export async function launchTui(opts: LaunchOptions): Promise<TuiSession> {
217217
} catch {
218218
// already gone
219219
}
220-
// give the process a beat to exit cleanly before returning
221-
await Promise.race([exited, new Promise((r) => setTimeout(r, 1000))])
220+
// Give the process a beat to exit cleanly, then escalate to SIGKILL if it
221+
// hasn't. A child that traps/ignores SIGTERM (or is slow to tear down its
222+
// render loop + worker) would otherwise be left orphaned when dispose()
223+
// returns — a silent test-process leak on CI.
224+
const exitedCleanly = await Promise.race([
225+
exited.then(() => true),
226+
new Promise<boolean>((r) => setTimeout(() => r(false), 1000)),
227+
])
228+
if (!exitedCleanly) {
229+
try {
230+
child.kill("SIGKILL")
231+
} catch {
232+
// already gone
233+
}
234+
await Promise.race([exited, new Promise((r) => setTimeout(r, 500))])
235+
}
222236
},
223237
exited,
224238
}

0 commit comments

Comments
 (0)