-
-
Notifications
You must be signed in to change notification settings - Fork 31.5k
process: unhandledRejection support more errors #41682
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
process: unhandledRejection support more errors #41682
Conversation
c5093df
to
a03aed8
Compare
Support cross realm errors where `instanceof` errors in our unhandledRejection warning to print better error with stack traces.
a03aed8
to
0f493e9
Compare
This comment has been minimized.
This comment has been minimized.
OMG I think CI just passed on the first try this has to be telling me something I'm going to go buy a lottery ticket 🤩 |
// Unhandled rejections trigger two warning per rejection. One is the rejection | ||
// reason and the other is a note where this warning is coming from. | ||
process.on('warning', common.mustCall(4)); | ||
process.on('warning', common.mustCall((reason) => { |
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 will happen if --unhandled-rejections=throw
(which is the default nowadays)
does this test cover it? the title says unhandled-warn
so maybe not this test, maybe need to add to modify another test which handles the throw
value?
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.
@ItamarGronich there is a separate test for test-promise-unhandled-throw
though that's harder to test given it's process output.
@aduh95 can I get a review/lgtm I want to do more work on this area of the code and don't wanna float :)? |
function isErrorLike(o) { | ||
return typeof o === 'object' && | ||
o !== null && | ||
ObjectPrototypeHasOwnProperty(o, 'stack'); |
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.
might want to use Object.hasOwn()
:)
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.
@bnb I wanted to but then we can't backport it to older versions of Node - see discussion here: #41682 (comment)
Commit Queue failed- Loading data for nodejs/node/pull/41682 ✔ Done loading data for nodejs/node/pull/41682 ----------------------------------- PR info ------------------------------------ Title process: unhandledRejection support more errors (#41682) Author Benjamin Gruenbaum (@benjamingr) Branch benjamingr:unhandled-rejection-cross-realm-stack -> nodejs:master Labels process, promises, errors, needs-ci Commits 2 - process: unhandledRejection support more errors - add test Committers 1 - Benjamin Gruenbaum PR-URL: https://github.com/nodejs/node/pull/41682 Refs: https://github.com/nodejs/node/issues/41676 Reviewed-By: Nitzan Uziely Reviewed-By: Tierney Cyren ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/41682 Refs: https://github.com/nodejs/node/issues/41676 Reviewed-By: Nitzan Uziely Reviewed-By: Tierney Cyren -------------------------------------------------------------------------------- ℹ This PR was created on Mon, 24 Jan 2022 18:51:28 GMT ✔ Approvals: 2 ✔ - Nitzan Uziely (@linkgoron): https://github.com/nodejs/node/pull/41682#pullrequestreview-863862772 ✔ - Tierney Cyren (@bnb): https://github.com/nodejs/node/pull/41682#pullrequestreview-866484825 ✔ Last GitHub CI successful ℹ Last Full PR CI on 2022-01-25T12:47:18Z: https://ci.nodejs.org/job/node-test-pull-request/42134/ - Querying data for job/node-test-pull-request/42134/ ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ No git cherry-pick in progress ✔ No git am in progress ✔ No git rebase in progress -------------------------------------------------------------------------------- - Bringing origin/master up to date... From https://github.com/nodejs/node * branch master -> FETCH_HEAD ✔ origin/master is now up-to-date - Downloading patch for 41682 From https://github.com/nodejs/node * branch refs/pull/41682/merge -> FETCH_HEAD ✔ Fetched commits as 0172d1d48cb6..9a234a525fda -------------------------------------------------------------------------------- [master 1764276c66] process: unhandledRejection support more errors Author: Benjamin Gruenbaum Date: Mon Jan 24 20:47:11 2022 +0200 1 file changed, 12 insertions(+), 4 deletions(-) [master 8833fb3264] add test Author: Benjamin Gruenbaum Date: Tue Jan 25 14:33:05 2022 +0200 2 files changed, 26 insertions(+), 5 deletions(-) ✔ Patches applied There are 2 commits in the PR. Attempting autorebase. Rebasing (2/4)https://github.com/nodejs/node/actions/runs/1763130093 |
Landed in 64c4b55 |
Support cross realm errors where `instanceof` errors in our unhandledRejection warning to print better error with stack traces. PR-URL: nodejs#41682 Refs: nodejs#41676 Reviewed-By: Nitzan Uziely <linkgoron@gmail.com> Reviewed-By: Tierney Cyren <hello@bnb.im>
Support cross realm errors where
instanceof
errors in ourunhandledRejection warning to print better error with stack traces.
This means that unhandled rejection warnings will print better cross-realm errors with
--unhandled-rejections=warn
Refs: #41676