fix(dev): exit non-zero when Electron is killed by a signal (#918)

`ChildProcess`'s `close` event fires as `(code, signal)` and `code` is null when the
child was terminated by a signal. `process.exit` ignores its second argument and
coerces null to 0, so passing the listener directly reports every signal death as a
successful exit.

Handle the two arguments explicitly so a signal death exits non-zero.
This commit is contained in:
Praveens-Pepper-AI 2026-09-28 22:33:35 -04:00 committed by GitHub
parent 98d30e57e3
commit 816c6dac61
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -165,7 +165,10 @@ export function startElectron(root: string | undefined): ChildProcess {
const entry = process.env.ELECTRON_ENTRY || '.'
const ps = spawn(electronPath, [entry].concat(args), { stdio: 'inherit' })
ps.on('close', process.exit)
// `code` is null when the child was terminated by a signal, and `process.exit` ignores
// its second argument, so passing the listener directly would report every crash as a
// successful exit. Map a signal death to a non-zero status instead.
ps.on('close', (code, signal) => process.exit(code ?? (signal ? 1 : 0)))
return ps
}