New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Winston doesn't log/parse a caught error from an exception #1771
Comments
I believe this may be due to inconsistent behavior between winston loggers and transports when applying formats. In winston-transport, part of the TransportStream _write function does this:
The relevant code in winston/logger.js looks like it does this:
Here's a simplified repro of the issue.
It's not clear to me which behavior should be preferred. |
I wonder if this is also the same case when winston doesn't properly log some objects and prints it as |
@jleverenz |
Please tell us about your environment:
winston
version? 3.2.1winston@2
winston@3
node -v
outputs: v12.8.1What is the problem?
Winston doesn't seem to log exceptions, it doesn't seem to properly parse the error object.
Further debugging using VSCode debugger
What do you expect to happen instead?
I expect Winston to log the caught error from the try...catch block. If I instead pass in
ex.message
instead of justex
, it properly outputs.ex
is defined all throughout the catch block, but Winston doesn't seem capable of parsing it for some reason.Other information
Further more, if I
return ex
from within the catch block, and then surround everything within another catch block, it seems to properly output it. For more on this unusual behavior, please see a gist here of a support post I made on Discord before I realized this is a bug with Winston.Additionally, I think this error also entails the issue another user has had for the past month over at #1758
The text was updated successfully, but these errors were encountered: