[nestjs] Incorrect shutdown
See original GitHub issueStarting 13.8.4 (when @nrwl/node:execute
was replaced by @nrwl/node:node
) Nx incorrectly handles shutdown on NestJS apps with shutdown hook.
Steps to Reproduce
- Create an empty NestJS app using Nx
- Use the following AppModule
- Enable shutdown hooks
- Start the app using
nx serve
- Send SIGTERM (Ctrl + C)
Current Behavior
1 log message:
onModuleDestroy before wait
Expected Behavior
3 log messages:
onModuleDestroy before wait
onModuleDestroy after wait
onApplicationShutdown
Environment
Node : 17.5.0
OS : darwin arm64
yarn : 3.2.0
nx : 13.8.5
@nrwl/angular : undefined
@nrwl/cli : 13.8.5
@nrwl/cypress : undefined
@nrwl/detox : undefined
@nrwl/devkit : 13.8.5
@nrwl/eslint-plugin-nx : 13.8.5
@nrwl/express : undefined
@nrwl/jest : 13.8.5
@nrwl/js : 13.8.5
@nrwl/linter : 13.8.5
@nrwl/nest : 13.8.5
@nrwl/next : undefined
@nrwl/node : 13.8.5
@nrwl/nx-cloud : undefined
@nrwl/react : undefined
@nrwl/react-native : undefined
@nrwl/schematics : undefined
@nrwl/storybook : undefined
@nrwl/tao : 13.8.5
@nrwl/web : undefined
@nrwl/workspace : 13.8.5
typescript : 4.6.2
rxjs : 7.5.4
---------------------------------------
Community plugins:
@nx-tools/nx-docker: 2.3.0
Issue Analytics
- State:
- Created 2 years ago
- Reactions:8
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Nest.js gracefully shutdown [duplicate] - Stack Overflow
I believe your problem might be that your NestJS instance is not listening for shutdown events. You need to enable that behavior with...
Read more >Let It Crash: Best Practices for Handling Node.js Errors on ...
Some strategies to gracefully shutdown the Node.js process and quickly restart your application after a catastrophic error terminates your ...
Read more >Rate Limiting | NestJS - A progressive Node.js framework
A common technique to protect applications from brute-force attacks is rate-limiting. To get started, you'll need to install the @nestjs/throttler package.
Read more >Automatically restart Node.js apps with Nodemon
Nodemon tutorial: Automatically restart Node.js apps with Nodemon ... a new framework for building binaries; Compare NestJS vs. Express.js ...
Read more >Best Practices for Node.js Error-handling - Toptal
They mean the code itself has some issues to solve and was coded wrong. ... Does it make sense to restart an application...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@nartc why was this closed?
Using latest everything from nx, I am still experiencing the original behavior noted by @mark-b-ab.
@nartc bumping this again.