express-pino-logger icon indicating copy to clipboard operation
express-pino-logger copied to clipboard

log not output on timeout

Open daveisfera opened this issue 6 years ago • 4 comments
trafficstars

I was trying to move from morgan to express-pino-logger but noticed that a log is not output when there's a timeout. morgan will output it with a status code of - but express-pino-logger doesn't output anything. Is there a setting to enable that output?

daveisfera avatar Jul 08 '19 20:07 daveisfera

Have you got a snippet to reproduce the problem? Would you like to send a PR to fix this?

mcollina avatar Jul 09 '19 14:07 mcollina

The issue is that the close event isn't being handled: https://nodejs.org/api/http.html#http_event_close_1

I feel like that should have a different msg than request completed, like connection closed. To my knowledge, there's not a way to distinguish that like how err and statusCode are checked for the error event handling. So does it need to be it's own function?

daveisfera avatar Jul 10 '19 21:07 daveisfera

Also, in my quick testing by adding the event, it incorrectly logs statusCode as 200 when the connection is closed.

daveisfera avatar Jul 10 '19 21:07 daveisfera

What appears to be happening with statusCode is that express is setting the res.statusCode to 200 and then that's being output, so that's probably more argument for the handler of the close event to be it's own function.

daveisfera avatar Jul 11 '19 17:07 daveisfera