Skip to content

fix(start): skip signal forwarding in watch mode#3338

Merged
kamilmysliwiec merged 1 commit intonestjs:masterfrom
maruthang:fix/issue-3158-watch-mode-regression
Apr 9, 2026
Merged

fix(start): skip signal forwarding in watch mode#3338
kamilmysliwiec merged 1 commit intonestjs:masterfrom
maruthang:fix/issue-3158-watch-mode-regression

Conversation

@maruthang
Copy link
Copy Markdown
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[x] Bugfix

What is the current behavior?

After #3313 (fix for async shutdown hooks), watch mode (nest start --watch) requires pressing CTRL+C twice to exit. The signal forwarding handlers keep the parent process alive waiting for the child to exit, but in watch mode the watcher restarts the child, preventing clean termination.

Reported by @johaven in #3158.

Issue Number: #3158

What is the new behavior?

Signal forwarding (SIGINT/SIGTERM) is now only registered in non-watch mode. In watch mode, the original behavior is preserved — CTRL+C immediately terminates via the exit handler and treeKillSync.

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

  • Graceful shutdown hooks still work correctly in non-watch mode (nest start)
  • Watch mode uses treeKillSync on exit as before
  • Added 2 regression tests for watch mode signal handling

the signal forwarding added for graceful shutdown caused watch
mode to require double ctrl+c to exit. signal handlers are now
only registered in non-watch mode.
@kamilmysliwiec kamilmysliwiec merged commit 436eecc into nestjs:master Apr 9, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants