Skip to content
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

Do Not Concatenate Error Message When An Error Stack is Present #1664

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mgreenw
Copy link

@mgreenw mgreenw commented Jun 26, 2019

Fixes: #1660

Normally, the functionality described to concatenate the message properties of additional meta objects makes sense. However, when the meta object is an Error, this does not make sense: a custom printf that prints the stack will double-print the Error.message as it is by default included in the Error.stack.

Example:

error: Exception raised when calling methodConnection closed.                                                        
Error: Connection closed.                                                                                                
    at WebSocket.closeListener (C:\Users\me\Desktop\project\src\index.js:96:16)              
    at WebSocket.emit (events.js:194:15)                                                                                 
    at WebSocket.emitClose (C:\Users\me\Desktop\project\node_modules\ws\lib\websocket.js:191:10)                  
    at Socket.socketOnClose (C:\Users\me\Desktop\project\node_modules\ws\lib\websocket.js:850:15)                 
    at Socket.emit (events.js:189:13)                                                                                    
    at TCP._handle.close (net.js:597:12)

Therefore, if a stack property exists in the meta object, do not append the message to the initial message.

Related:
#1338

Max Greenwald and others added 2 commits June 26, 2019 14:48
Fix note to ensure that the message will not be concatenated when a `stack` property is available.
@codyzu
Copy link

codyzu commented Jul 17, 2019

Any progress on this? I don't like the concatenated message for errors. This would be great!

@codyzu
Copy link

codyzu commented Jul 17, 2019

In the meantime, I wrote a formatter that can be used as a workaround: #1660 (comment)

@mgreenw
Copy link
Author

mgreenw commented Jul 17, 2019

@codyzu I made a very similar custom formatter as a temporary solution!

In terms of progress...I'm not a maintainer so I'm not sure what to do until this is reviewed. I know the tests are failing - I'm looking into it now.

@DABH - what are the next steps on this?

@mgreenw
Copy link
Author

mgreenw commented Jul 17, 2019

@codyzu I fixed the failing tests, so all that should be left is getting approval for this change.

@mgreenw
Copy link
Author

mgreenw commented Aug 23, 2019

@DABH Would you be able to look at this when you get a chance? Thanks!

@sondremare
Copy link

Has this been fixed in another commit? Or why is this not merged?

@yaro90
Copy link

yaro90 commented Dec 1, 2023

Any reason not to include this? Thanks

@DABH
Copy link
Contributor

DABH commented Jan 3, 2024

Hi there! Sorry, with essentially no funding for winston it's been hard to keep up with PRs beyond maintenance.

Can someone provide an example of current behavior and behavior with the proposed change?

I'm worried that this is a breaking change and would require a major version bump. Maybe that's what we should do, but would like to hear from folks on that. Or maybe I'm misunderstanding and this isn't a breaking change. I recall that a lot of folks had issues with the way Errors were treated with winston@3, but it's been so long since that release that I imagine most of the community has adapted, so I don't want to break all their stuff again in 3.x with a better solution (but if this is important enough we could start looking at 4.0, it would be helpful if we had some other changes to make to justify such a release).

Thank you for your contribution and for perhaps years of patience on this issue... 🥲

@DABH
Copy link
Contributor

DABH commented Jan 3, 2024

(Of course, this branch would be have to be brought up to date as well or a new/equivalent PR be opened...)

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

Successfully merging this pull request may close these issues.

Error.message being appended to info.message
5 participants