From 12e888126ccf968193e7570a68db1bc35f90d52d Mon Sep 17 00:00:00 2001 From: Quentin Date: Wed, 20 Sep 2023 00:19:52 +0200 Subject: [PATCH] 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> --- packages/next/src/server/lib/start-server.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/next/src/server/lib/start-server.ts b/packages/next/src/server/lib/start-server.ts index 21585afea1..88de4cf513 100644 --- a/packages/next/src/server/lib/start-server.ts +++ b/packages/next/src/server/lib/start-server.ts @@ -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)