-
Notifications
You must be signed in to change notification settings - Fork 33
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
Explicitly check cause
property on Error
instances
#94
Comments
Go for it, would you like to send a Pull Request to address this issue? Remember to add unit tests. |
Yeah, I should be able to take a stab at it. I'm slightly confused actually, at first glance, it looks like the cause should be getting included in the message/stack based on https://github.com/pinojs/pino-std-serializers/blob/master/lib/err.js#L56-L57, which uses the error helpers, and since those don't depend on enumerable properties, not sure why they're actually missing all together. With that being said, I only looked through it at a glance, will explore a bit more this week if I can get some time. |
The first step is to write a failing test. |
Is there any news on this? Otherwise I might try and do it |
@hypesystem go for it! |
Having almost finished writing the code for this, I noticed that I think these two things are ... kind of redundant when they both exist? Is there a use case for wanting both the error message to be constructed from Personally, I would prefer the serialized result, as it would contain stack traces of the original Errors, but I'd like some input on how to progress here. What are your opinions? |
I've added a PR on this #105, but pending my previous questions, I'm wondering if we should clean up the message serialization in the same PR. |
They are also preserved: pino-std-serializers/lib/err.js Line 62 in d8ce240
|
Instead rely on its content being appended to the message and the stack. This is an alternative fix to pinojs#94, replacing pinojs#105 and pinojs#108 + makes pinojs#109 not needed
…ead (#110) * Revert "Nested VError causes (#108)" This reverts commit 5b88f7e. * Revert "Serialize errors with cause (#105)" This reverts commit ae83956. * Never serialize `.cause` when an `Error` Instead rely on its content being appended to the message and the stack. This is an alternative fix to #94, replacing #105 and #108 + makes #109 not needed * Add tests * Add explainer comment
The current error serializer only walks enumerable properties using a
for..in
loop. The downside to this is that vanilla errors with theircause
property set are not enumerable by default. I don't know if it's spec related or just specific to V8's implementation, but it's a bit wonky/unexpected nonetheless.This means if you have the following code, the
cause
property won't actually be logged/printed. It will only log the very first/top-level error.Here's what node's inspector prints:
Would people be open to a PR that explicitly checks for a
cause
key alongside the existingfor..in
check? Are there other ways to achieve this? It seems like this would be an expected/sane default, but perhaps there are downsides to doing this or was previously not done intentionally?Thanks.
The text was updated successfully, but these errors were encountered: