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

Invalid JSON logged when toString function returns undefined #525

Closed
NiXXeD opened this issue Oct 2, 2018 · 2 comments
Closed

Invalid JSON logged when toString function returns undefined #525

NiXXeD opened this issue Oct 2, 2018 · 2 comments

Comments

@NiXXeD
Copy link

NiXXeD commented Oct 2, 2018

Similar to #456

We found a situation where a some errors we were logging had the output contain "toString":[object Undefined]. This isn't valid JSON and was causing our log aggregator parser to break.

In playing with it, I am able to reproduce this by:

const pino = require('pino')()
const err = new Error('Blah')
err.toString = () => undefined
pino.error(err, 'Something bad happened.')

The full output then is this, which is not valid JSON.

{
  "level": "error",
  "time": 1538513586038,
  "msg": "Something bad happened.",
  "pid": 4086,
  "hostname": "dev.local",
  "type": "Error",
  "stack": "...",
  "toString": [object Undefined],
  "v": 1
}

I'm guessing this isn't exactly how it's produced, but this is a way to reproduce the same situation.

@NiXXeD
Copy link
Author

NiXXeD commented Oct 3, 2018

Yup this is fixed as of 5.6.3. Thank you!

@mcollina mcollina closed this as completed Oct 3, 2018
@github-actions
Copy link

github-actions bot commented Feb 9, 2022

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 9, 2022
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