nestjs / nest

A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀
https://nestjs.com
MIT License
66.89k stars 7.56k forks source link

NestJS Graceful shutdown #12913

Closed JuTiger-Lee closed 9 months ago

JuTiger-Lee commented 9 months ago

Is there an existing issue for this?

Current behavior

I tried graceful shutdown but I failed I first used @nestjs/typeorm package, but This package db connection close before the work is finished

I tried process like this

  1. Database record lock in workbench
  2. lock wating in nestjs application
  3. excute command pm2 restart different terminal
  4. lock clear(excute command is "ROLLBAKC") in workbench
  5. excute query in nestjs application
  6. excute error message "[TypeORMError: Connection is not established with mysql database" in nestjs application

and I next used typeorm package, This package is ignore and server exist

When Nestjs try graceful shutdown, Nestjs should confirm event loop stack and thread pool The current method is unsafe

Minimum reproduction code

notthing

Steps to reproduce

  1. Database record lock in workbench
  2. lock wating in nestjs application
  3. excute command pm2 restart different terminal
  4. lock clear(excute command is "ROLLBAKC") in workbench
  5. excute query in nestjs application
  6. excute error message "[TypeORMError: Connection is not established with mysql database" in nestjs application

Expected behavior

I think When Nestjs try graceful shutdown, Nestjs should confirm event loop stack and thread pool

Package

Other package

@nestjs/tyeprom

NestJS version

9.0.0

Packages versions

{
 "dependencies": {
   "@nestjs/tyeprom": "^9.0.0",
   "@nestjs/common": "^9.0.0",
   "@nestjs/core": "^9.0.0",
   "@nestjs/microservices": "^9.2.1",
   "typerom": "^0.3.7",
   ....
}
}

Node.js version

v18.19.0

In which operating systems have you tested?

Other

No response

kamilmysliwiec commented 9 months ago

Thank you for taking the time to submit your report! From the looks of it, this could be better discussed on our Discord. If you haven't already, please join here and send a new post in the #⁠ 🐈 nestjs-help forum. Make sure to include a link to this issue, so you don't need to write it all again. We have a large community of helpful members, who will assist you in getting this to work.