Skip to content

Nodemon not respecting graceful shutdown #2238

Closed
@bugs181

Description

  • Versions: node@v20.18.0, linux@6.11.3-200.fc40.x86_64
  • nodemon -v: 3.1.7
  • Operating system/terminal environment (powershell, gitshell, etc): embedded bash in VSCode 1.95.2
  • Command you ran: nodemon --signal SIGTERM

Expected behaviour

When running the code directly via node index.js the result is as expected

$ node index.js

[scanner] Resuming work
Job 970923B9DDFA472AF33E73F9E00CB8781004360D stalled and will be reprocessed
^CExiting due to signal SIGINT
Shutting down
[service] Disconnecting
[service] TODO: cleanup
Stopping workers
stopWorker()
here
Finished clean shutdown

Actual behaviour

When running via nodemon index.js or nodemon --signal SIGTERM the process is killed too early.

$ nodemon --signal SIGTERM

[nodemon] 3.1.7
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,cjs,json
[nodemon] starting `node index.js`
[scanner] Resuming work
Job 970923B9DDFA472AF33E73F9E00CB8781004360D stalled and will be reprocessed
^CExiting due to signal SIGINT
Shutting down
[service] Disconnecting
[service] TODO: cleanup
Stopping workers
stopWorker()

Steps to reproduce

I am using async-cleanup to listen for the events. This doesn't appear to do anything special. It hooks into the following signals, then awaits the result of user-code gracefulShutdown before sending a process.exit(0)

Events listened to:

const listenedSignals = [
  "SIGBREAK", // Ctrl-Break on Windows
  "SIGHUP", // Parent terminal closed
  "SIGINT", // Terminal interrupt, usually by Ctrl-C
  "SIGTERM", // Graceful termination
  "SIGUSR2", // Used by Nodemon
] as const;

It appears that nodemon is not respecting the SIGINT (CTRL + C) signal and is killing the process early.

Metadata

Assignees

No one assigned

    Labels

    staleno activity for 2 weeks

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions