If you pipe pino to get a nicely formatted output for your logs using ctrl-c can cause the server
to throw an exception.
This is because the shell will send SIGINT to both pino and your server code.
pino will immediately exit but if your server is trying to do some graceful termination and logging in he process it will crash since pino already closed stdout.
If you pipe
pino
to get a nicely formatted output for your logs using ctrl-c can cause the server to throw an exception. This is because the shell will send SIGINT to both pino and your server code. pino will immediately exit but if your server is trying to do some graceful termination and logging in he process it will crash since pino already closed stdout.Example server code -
if you run
node server.js | pino
and terminate the process using ctrl-c the following error is thrown -