-
Notifications
You must be signed in to change notification settings - Fork 878
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
Invalid error JSON logged if stack is undefined #456
Comments
That’s definitely a bug! Out of curiosity.. why are you removing .stack? |
Hey @mcollina. Thanks for the quick reply. The code attached is strictly a way to reproduce the issue. The real world case affecting me is trying to log instances of |
For more context this what an ApolloError looks like: https://github.com/apollographql/apollo-server/blob/master/packages/apollo-server-errors/src/index.ts#L3 |
I'm guessing this line is the culprit: https://github.com/pinojs/pino/blob/v4.17.3/pino.js#L149 data += ',"type":"Error","stack":' + this.stringify(obj.stack) might have to change to: data += ',"type":"Error"'
data += obj.stack ? ',"stack":' + this.stringify(obj.stack) : '' If that's the case then I'm happy to submit a PR |
Please do so! Would you mind adding a unit test as well?
Il giorno ven 20 lug 2018 alle 14:46 George Haidar <notifications@github.com>
ha scritto:
… I'm guessing this line is the culprit:
https://github.com/pinojs/pino/blob/v4.17.3/pino.js#L149
data += ',"type":"Error","stack":' + this.stringify(obj.stack)
might have to change to:
data += ',"type":"Error"'
data += obj.stack ? ',"stack":' + this.stringify(obj.stack) : ''
If that's the case then I'm happy to submit a PR
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#456 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AADL4-Dw6Y0XbetJYniY3_UwUK4buxLNks5uIdEPgaJpZM4VX6Sx>
.
|
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
To reproduce:
Note the section
"stack":undefined
which is not valid JSON.Real world example: Apollo GraphQL has a custom error class called ApolloError that does not hold
stack
property. When logging an ApolloError we see the issue above which breaks pino's pretty printer among other things.Pino version: 4.17.3
The text was updated successfully, but these errors were encountered: