Is there an existing issue for this?
Current behavior
When using pino as logger for application and enableShutdownHooks, Nest doesn't wait for it to write all logs before exiting.
If app.enableShutdownHooks() is not used and shutdown hooks added manually on process.once for SIGINT/SIGTERM/etc, then pino is able to finish its logging, but if we enable Nest.js shutdown hooks - there is something under the hood that has impact on pino finalization.
Would be nice to understand what is the conflict and how to avoid it to support both.
Minimum reproduction code
https://codesandbox.io/p/devbox/recursing-lamarr-qjh9hh
Steps to reproduce
- Clone/fork code
npm install
npm start
- Wait app until app is up and running
- Press
Ctrl+C or send kill -2/kill -15 to pid
Expected behavior
Nest shutdown process doesn't interrupt pino to write all necessary logs that are buffered.
NestJS version
11.1.9
Packages versions
{
"@nestjs/common": "^11.1.9",
"@nestjs/core": "^11.1.9",
"@nestjs/platform-express": "^11.1.9",
"pino": "^10.1.0",
"pino-pretty": "^13.1.2",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.1"
}
Node.js version
v20.12.1 (and others)
In which operating systems have you tested?
Other
No response
Is there an existing issue for this?
Current behavior
When using pino as logger for application and
enableShutdownHooks, Nest doesn't wait for it to write all logs before exiting.If
app.enableShutdownHooks()is not used and shutdown hooks added manually onprocess.onceforSIGINT/SIGTERM/etc, then pino is able to finish its logging, but if we enable Nest.js shutdown hooks - there is something under the hood that has impact on pino finalization.Would be nice to understand what is the conflict and how to avoid it to support both.
Minimum reproduction code
https://codesandbox.io/p/devbox/recursing-lamarr-qjh9hh
Steps to reproduce
npm installnpm startCtrl+Cor sendkill -2/kill -15to pidExpected behavior
Nest shutdown process doesn't interrupt
pinoto write all necessary logs that are buffered.NestJS version
11.1.9
Packages versions
{ "@nestjs/common": "^11.1.9", "@nestjs/core": "^11.1.9", "@nestjs/platform-express": "^11.1.9", "pino": "^10.1.0", "pino-pretty": "^13.1.2", "reflect-metadata": "^0.2.2", "rxjs": "^7.8.1" }Node.js version
v20.12.1 (and others)
In which operating systems have you tested?
Other
No response