Skip to content

Commit

Permalink
fix: handle string nodejs signals (#55606)
Browse files Browse the repository at this point in the history
## 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>
  • Loading branch information
Yovach and huozhi committed Sep 19, 2023
1 parent 7e17de9 commit 12e8881
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/next/src/server/lib/start-server.ts
Expand Up @@ -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)

Expand Down

0 comments on commit 12e8881

Please sign in to comment.