node-dev icon indicating copy to clipboard operation
node-dev copied to clipboard

Node-dev does not send SIGTERM on CTRL+C

Open macjabeth opened this issue 2 years ago • 1 comments

My package.json script uses the node-dev CLI to run code with the event listener:

process.on('SIGTERM', () => {
  console.log('SIGTERM fired...');
});

When I use CTRL+C to halt the server, I get no console notifications.

This should be handled so we can properly exit node-dev servers with CTRL+C. Thank you!

macjabeth avatar Apr 21 '22 14:04 macjabeth

From https://nodejs.org/api/process.html#signal-events

'SIGTERM' and 'SIGINT' have default handlers on non-Windows platforms that reset the terminal mode before exiting with code 128 + signal number. If one of these signals has a listener installed, its default behavior will be removed (Node.js will no longer exit).

If you add a SIGTERM handler, you are expected to shutdown the process yourself either by calling process.exit or removing all listeners.

bjornstar avatar Apr 22 '22 10:04 bjornstar