mirror of
https://github.com/deepseek-ai/deepseek-harness
synced 2026-08-15 21:04:50 +00:00
fix(subprocess): prioritize host-exit cleanup listener
This commit is contained in:
@@ -48,7 +48,7 @@ export class LocalSubprocessService extends SubprocessService {
|
||||
super(ctx)
|
||||
ctx.effect(() => {
|
||||
const onHostExit = (): void => { this.terminateForHostExit() }
|
||||
process.on('exit', onHostExit)
|
||||
process.prependListener('exit', onHostExit)
|
||||
return async () => {
|
||||
try {
|
||||
await this.disposeManagedProcesses()
|
||||
|
||||
@@ -21,6 +21,23 @@ function spec(command: string, overrides: Partial<SubprocessSpawnSpec> = {}): Su
|
||||
}
|
||||
|
||||
describe('LocalSubprocessService', () => {
|
||||
it('places the host-exit finalizer before listeners that predate the service', async () => {
|
||||
const baseline = new Set(process.listeners('exit'))
|
||||
const prior = vi.fn()
|
||||
process.on('exit', prior)
|
||||
const ctx = new Context()
|
||||
const fiber = await ctx.plugin(LocalSubprocessService)
|
||||
try {
|
||||
const listeners = process.listeners('exit')
|
||||
const finalizer = listeners.find(candidate => !baseline.has(candidate) && candidate !== prior)
|
||||
expect(finalizer).toBeTypeOf('function')
|
||||
expect(listeners.indexOf(finalizer!)).toBeLessThan(listeners.indexOf(prior))
|
||||
} finally {
|
||||
process.off('exit', prior)
|
||||
await fiber.dispose()
|
||||
}
|
||||
})
|
||||
|
||||
it('keeps the host-exit finalizer active until normal disposal reaches quiescence', async () => {
|
||||
const before = new Set(process.listeners('exit'))
|
||||
const ctx = new Context()
|
||||
|
||||
Reference in New Issue
Block a user