-
Notifications
You must be signed in to change notification settings - Fork 153
Feature request: Include cause in stack trace #1361
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
Comments
Hi @everett1992, thank you for opening this issue. I agree with you that having the I'm going to add this to the backlog and also mark it as If anyone is interested in picking this up, please leave a comment below to agree on the scope with a maintainer and ask any question before starting to work on a PR. |
Hello @dreamorosi I would like to work on the PR. |
Hi @dVp007, thank you for offering to work on this issue. Unfortunately after looking into it a bit more, I don't think we can support the feature just yet. The I should have checked this better before marking the feature as If you're still interested in contributing, I'd encourage you to look for other issues marked as |
I think this can be implemented while supporting node 14. `if
(error.cause)` should not cause issues on any runtime
…On Fri, Mar 10, 2023, 2:39 AM Andrea Amorosi ***@***.***> wrote:
Hi @dVp007 <https://github.com/dVp007>, thank you for offering to work on
this issue.
Unfortunately after looking into it a bit more, I don't think we can
support the feature just yet. The cause field was added in Node.js
starting from version v16.9.0 (source
<https://nodejs.org/api/errors.html#errorcause>), and at the moment we
are committed to offer feature parity for versions 14.x through 18.x, which
means we can't offer this feature for the time being.
I should have checked this better before marking the feature as
status/confirmed, apologies for the confusion. I'm going to mark this as
status/blocked and we'll revisit this once we decide to drop support for
Node.js 14.x. We don't have an ETA to share at the moment but it'll likely
happen sometime after Lambda will announce its deprecation or EOL.
------------------------------
If you're still interested in contributing, I'd encourage you to look for
other issues marked as good-first-issue. Thank you for your understanding.
—
Reply to this email directly, view it on GitHub
<#1361 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAE6WM4VTGDYDUR7SYXLO5LW3MAHFANCNFSM6AAAAAAVVQ54KE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
|
@dreamorosi Can you please elaborate on your reasoning not to support error cause. This language feature is a major improvement to error handling and logging, and the decision not to support it in Powertools is quite surprising. If user code targets ES2022 and supporting node versions (>= Powertools is preventing us from using a modern language feature. Just as with other language features, there is no expectation for Powertools to polyfill this feature for older node versions. |
i am also interested in this feature of supporting the |
Hi both, thank you for taking the time to show interest in this feature - this definitely helps us with prioritization and to understand demand. My initial push back towards adding the feature came from wanting to offer a cohesive Powertools experience across runtimes. Since the issue was opened however there seems to be a lot more demand that I anticipated so I'm more than open to reconsider. On a general level I'm not keen on introducing a polyfill and after an initial proof of concept, the approach suggested by @everett1992 here, seems to be enough. Given that the Node API doesn't seem to specify any strong type/value for
logger.error(
"something went wrong",
new Error("boom", { cause: new Error("foo") })
);
// prints
{
"level": "ERROR",
"message": "something went wrong",
"service": "service_undefined",
"timestamp": "2023-07-14T11:53:06.944Z",
"error": {
"name": "Error",
"location": "/Users/aamorosi/Codes/error-cause/index.ts:8",
"message": "boom",
"stack": "Error: boom\n at Object.<anonymous> (/Users/aamorosi/Codes/error-cause/index.ts:8:3)\n at Module._compile (node:internal/modules/cjs/loader:1159:14)\n at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)\n at Module.load (node:internal/modules/cjs/loader:1037:32)\n at Module._load (node:internal/modules/cjs/loader:878:12)\n at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)\n at node:internal/main/run_main_module:23:47",
"cause": {
"name": "Error",
"location": "/Users/aamorosi/Codes/error-cause/index.ts:8",
"message": "foo",
"stack": "Error: foo\n at Object.<anonymous> (/Users/aamorosi/Codes/error-cause/index.ts:8:30)\n at Module._compile (node:internal/modules/cjs/loader:1159:14)\n at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)\n at Module.load (node:internal/modules/cjs/loader:1037:32)\n at Module._load (node:internal/modules/cjs/loader:878:12)\n at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)\n at node:internal/main/run_main_module:23:47"
}
}
} 2 Logging an error with cause of types other than logger.error("something went wrong", new Error("boom", { cause: "something" }));
// prints
{
"level": "ERROR",
"message": "something went wrong",
"service": "service_undefined",
"timestamp": "2023-07-14T11:53:06.959Z",
"error": {
"name": "Error",
"location": "/Users/aamorosi/Codes/error-cause/index.ts:13",
"message": "boom",
"stack": "Error: boom\n at Object.<anonymous> (/Users/aamorosi/Codes/error-cause/index.ts:13:38)\n at Module._compile (node:internal/modules/cjs/loader:1159:14)\n at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)\n at Module.load (node:internal/modules/cjs/loader:1037:32)\n at Module._load (node:internal/modules/cjs/loader:878:12)\n at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)\n at node:internal/main/run_main_module:23:47",
"cause": "something"
}
}
logger.error("something went wrong", new Error("boom"));
// prints
{
"level": "ERROR",
"message": "something went wrong",
"service": "service_undefined",
"timestamp": "2023-07-14T11:53:06.958Z",
"error": {
"name": "Error",
"location": "/Users/aamorosi/Codes/error-cause/index.ts:11",
"message": "boom",
"stack": "Error: boom\n at Object.<anonymous> (/Users/aamorosi/Codes/error-cause/index.ts:11:38)\n at Module._compile (node:internal/modules/cjs/loader:1159:14)\n at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)\n at Module.load (node:internal/modules/cjs/loader:1037:32)\n at Module._load (node:internal/modules/cjs/loader:878:12)\n at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)\n at node:internal/main/run_main_module:23:47"
}
} |
|
This is now released under v1.12.1 version! |
Use case
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause
Error's cause property is a useful way to provide extra information about an error, particularly because it is a structured object, rather than adding to the string message.
However powertools does not include cause in log messages
Solution/User Experience
powertools should include
cause
when it is defined.Alternative solutions
No response
Acknowledgment
Future readers
Please react with 👍 and your use case to help us understand customer demand.
The text was updated successfully, but these errors were encountered: