fix: handle string nodejs signals (#55606)

## Fixing a bug

### What?

On these versions, SIGINT signals are `string`, exit callback recieves code `number`

### How?

We use code argument to quit process for `event`, and exit with code `0` for `SIGINT` and `SIGTERM` signals 

Fixes #55605


Co-authored-by: Jiachi Liu <4800338+huozhi@users.noreply.github.com>
This commit is contained in:
Quentin 2023-09-20 00:19:52 +02:00 committed by GitHub
parent 7e17de9880
commit 12e888126c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -282,9 +282,10 @@ export async function startServer({
// This is the render worker, we keep the process alive
console.error(err)
}
process.on('exit', cleanup)
process.on('SIGINT', cleanup)
process.on('SIGTERM', cleanup)
process.on('exit', (code) => cleanup(code))
// callback value is signal string, exit with 0
process.on('SIGINT', () => cleanup(0))
process.on('SIGTERM', () => cleanup(0))
process.on('uncaughtException', exception)
process.on('unhandledRejection', exception)