fix(subagent): close terminal teardown races

This commit is contained in:
pku-xht
2026-08-04 20:26:45 +08:00
parent f96acad438
commit 451c2929ed
6 changed files with 135 additions and 30 deletions

View File

@@ -668,7 +668,6 @@ describe('coverage seams', () => {
it('terminate() after the tree died delivers no termination signal', async () => {
const running = spawnSubprocess(spec('true'))
await running.done
await running.waitForExit()
const spy = vi.spyOn(process, 'kill')
try {
running.terminate()
@@ -677,6 +676,21 @@ describe('coverage seams', () => {
} finally {
spy.mockRestore()
}
await running.waitForExit()
})
it('repeated terminate after exit never probes or signals a reused process group', async () => {
const running = spawnSubprocess(spec('sleep 60'))
running.terminate()
await running.done
await running.waitForExit()
const spy = vi.spyOn(process, 'kill').mockImplementation(() => true)
try {
running.terminate()
expect(spy).not.toHaveBeenCalled()
} finally {
spy.mockRestore()
}
})
it('waitForExit on a failed spawn reports exited immediately', async () => {