-
Notifications
You must be signed in to change notification settings - Fork 885
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
Apply err serializer everywhere. #896
Conversation
Be careful that this PR is bringing a breaking change if people were to leverage current behaviour. |
Agreed. |
TBH, I would consider that a bug in anybody codebase :(. @jsumners I think this is almost good to go. I do not see any other way in which we can fix the change without breaking anybody. |
Maybe it deserves a version bump with a breaking change notice in changelog. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but do we think this is a semver major?
I'm torn. I don't see why anybody would not want this change, however we have recently bumped major and I do not want this to sit there for a long cycle. This is be breaking if folks are relying on the difference between things. However this pops every now and then.. and I do not see why somebody would not want this. In fact, it is number 1 reason why I do not recommend |
} else { | ||
obj = Object.assign(mixin ? mixin() : {}, _obj) | ||
if (!msg && objError) { | ||
} else if (_obj instanceof Error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what versions did you find there was no slow down? I thought instanceof was expensive? Is that no longer true in 12 and 14?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instanceof
was already there. Now there is even a branching being skipped in opposition to the original code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need docs for this?
pino/browser.js serializer API needs to be synced with this
So the breaking change will be that if someone is using a custom error serializer and then do logger.info(err) the log output will now be different? |
Yes, we need docs. I forgot to block on that 🤦
The change is that if someone does |
AFAIK there isn't nothing at the moment, there is the error logged without passing it through the serializer. Hence |
Typically, |
There seems to be no documentation with this PR, so I'll just ask here if that is ok: does this mean we do not have to call the error object i.e. after this pr is merged: const foo = new Error('hello');
const bar = {a: 'b'};
logger.error({foo, bar}, foo.message); will result in |
No. This PR addresses |
@davidmarkclements the browser version requires no changes as far as I understand: https://github.com/pinojs/pino/blob/master/test/browser-serializers.test.js#L47-L66. Please confirm |
@mcollina 🤣 ok great, yeah confirmed. We've synchronised server pino with browser pino here instead hahaha. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@davidmarkclements @jsumners semver-major or semver-minor? |
You did! I'm passing that to @davidmarkclements! |
Any objection in shipping this in v6? @jsumners @davidmarkclements @delvedor @watson and possibly any others? |
If we use the justification that this fixes expected behavior, then we can do a minor release. Ideally, we'd issue a major out of an abundance of caution. But I am okay either way. |
I'm ok either way. We'll see if we can bump the major in Fastify. Let's do a major. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it can be shipped as a minor, maybe with a note in the docs for showing how to get the old behavior?
You can't get the old behavior, that's part of the problem. |
When export const logger = pino({
nestedKey: 'payload',
})
process.on('uncaughtException', final(logger, (err, finalLogger) => {
finalLogger.error(err, 'uncaughtException')
process.exit()
}))
throw Error('wow') // { level: 50, pid, hostname, payload: {}, message: "uncaughtException"} |
Landed in the |
* Apply err serializer everywhere. * Handle cases where the err serializer is not set * Added docs * Typo
* Apply err serializer everywhere. (#896) * Apply err serializer everywhere. * Handle cases where the err serializer is not set * Added docs * Typo * Merge error flows. (#923) Merge the 2 error flows: * if obj is of type Error wrap it in `{ err }` * if msg not present set to error message (if present) Update tests. Update API doc * Check for undefined value instead of falsy ones Co-authored-by: Matteo Collina <[email protected]> Co-authored-by: Mihai Voicescu <[email protected]>
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Apply the error serializer if the error object is top-level. It does not seem to cause any performance regressions from my checks.
Fixes #895