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

pino/browser: Error not serialized correctly #2132

Open
lennerd opened this issue Feb 19, 2025 · 1 comment
Open

pino/browser: Error not serialized correctly #2132

lennerd opened this issue Feb 19, 2025 · 1 comment

Comments

@lennerd
Copy link

lennerd commented Feb 19, 2025

Hey there,

we are using pino for the browser. Looks like the serializer for Error instances does not use the provided messageKey when serializing the error. The property from the error object are also not wrapped in an err object, like stated here: https://getpino.io/#/docs/api?id=errors

pino({ browser: { asObject: true, serialize: true }, messageKey: 'message' }).error(new Error('Something went wrong'));

Output in Node:

{"level":50,"time":1739977190475,"err":{"type":"Error","message":"Something went wrong","stack":"Error: Something went wrong ..."},"message":"Something went wrong"}

Output in the browser:

{"time":1739977722493,"level":50,"type":"Error","msg":"Something went wrong","stack":"Error: Something went wrong..."}

Are we doing something wrong?

@mcollina
Copy link
Member

Thanks for reporting! Browser mode is a bit odd tbh.

Would you like to send a Pull Request to address this issue? Remember to add unit tests.

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

No branches or pull requests

2 participants