diff --git a/src/main/daemon/daemon-child-exit-observer.test.ts b/src/main/daemon/daemon-child-exit-observer.test.ts index 1cd394131c9..20149348fcc 100644 --- a/src/main/daemon/daemon-child-exit-observer.test.ts +++ b/src/main/daemon/daemon-child-exit-observer.test.ts @@ -44,6 +44,20 @@ describe('observeDaemonChildExit', () => { observer.stop() }) + it('retains fatal stderr that arrives before the independent ready IPC callback', () => { + const child = createChild() + const onExit = vi.fn() + const observer = observeDaemonChildExit(child, onExit) + + child.stderr.write('FATAL ERROR before ready dispatch') + observer.markReady() + child.emit('close', 134, null) + + expect(onExit).toHaveBeenCalledWith( + expect.objectContaining({ stderrTail: 'FATAL ERROR before ready dispatch' }) + ) + }) + it('stops observing and destroys the startup pipe on launch failure', () => { const child = createChild() const destroy = vi.spyOn(child.stderr, 'destroy') diff --git a/src/main/daemon/daemon-child-exit-observer.ts b/src/main/daemon/daemon-child-exit-observer.ts index 94d9101884b..2af959ec425 100644 --- a/src/main/daemon/daemon-child-exit-observer.ts +++ b/src/main/daemon/daemon-child-exit-observer.ts @@ -72,7 +72,6 @@ export function observeDaemonChildExit( return } ready = true - stderrTail = Buffer.alloc(0) child.stderr?.on('error', onStderrError) child.stderr?.unref?.() child.on('close', onClose)