Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

log not output on timeout #36

Open
daveisfera opened this issue Jul 8, 2019 · 4 comments
Open

log not output on timeout #36

daveisfera opened this issue Jul 8, 2019 · 4 comments

Comments

@daveisfera
Copy link

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?

@mcollina
Copy link
Member

mcollina commented Jul 9, 2019

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

@daveisfera
Copy link
Author

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
Copy link
Author

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

@daveisfera
Copy link
Author

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants