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

process: unhandledRejection support more errors #41682

Conversation

benjamingr
Copy link
Member

Support cross realm errors where instanceof errors in our
unhandledRejection 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

@benjamingr benjamingr force-pushed the unhandled-rejection-cross-realm-stack branch from c5093df to a03aed8 Compare January 24, 2022 18:53
@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. process Issues and PRs related to the process subsystem. labels Jan 24, 2022
@benjamingr benjamingr added errors Issues and PRs related to JavaScript errors originated in Node.js core. promises Issues and PRs related to ECMAScript promises. request-ci Add this label to start a Jenkins CI on a PR. labels Jan 24, 2022
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jan 24, 2022
@nodejs-github-bot
Copy link
Collaborator

Support cross realm errors where `instanceof` errors in our
unhandledRejection warning to print better error with stack traces.
@benjamingr benjamingr force-pushed the unhandled-rejection-cross-realm-stack branch from a03aed8 to 0f493e9 Compare January 24, 2022 19:56
@benjamingr benjamingr added the request-ci Add this label to start a Jenkins CI on a PR. label Jan 24, 2022
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jan 24, 2022
@nodejs-github-bot
Copy link
Collaborator

@benjamingr

This comment has been minimized.

@benjamingr benjamingr added the request-ci Add this label to start a Jenkins CI on a PR. label Jan 25, 2022
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jan 25, 2022
@nodejs-github-bot
Copy link
Collaborator

@benjamingr
Copy link
Member Author

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) => {
Copy link

@ItamarGronich ItamarGronich Jan 26, 2022

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?

Copy link
Member Author

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.

@benjamingr
Copy link
Member Author

@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');
Copy link
Contributor

@bnb bnb Jan 27, 2022

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() :)

Copy link
Member Author

@benjamingr benjamingr Jan 27, 2022

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)

@benjamingr benjamingr added the commit-queue Add this label to land a pull request using GitHub Actions. label Jan 28, 2022
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Jan 28, 2022
@nodejs-github-bot
Copy link
Collaborator

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)

Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
process: unhandledRejection support more errors

Support cross realm errors where instanceof errors in our
unhandledRejection warning to print better error with stack traces.

PR-URL: #41682
Refs: #41676
Reviewed-By: Nitzan Uziely linkgoron@gmail.com
Reviewed-By: Tierney Cyren hello@bnb.im

[detached HEAD 647511a414] process: unhandledRejection support more errors
Author: Benjamin Gruenbaum benjamingr@gmail.com
Date: Mon Jan 24 20:47:11 2022 +0200
1 file changed, 12 insertions(+), 4 deletions(-)
Rebasing (3/4)
Rebasing (4/4)

Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
add test

PR-URL: #41682
Refs: #41676
Reviewed-By: Nitzan Uziely linkgoron@gmail.com
Reviewed-By: Tierney Cyren hello@bnb.im

[detached HEAD e6c16e2773] add test
Author: Benjamin Gruenbaum benjamingr@gmail.com
Date: Tue Jan 25 14:33:05 2022 +0200
2 files changed, 26 insertions(+), 5 deletions(-)

Successfully rebased and updated refs/heads/master.

ℹ Use --fixupAll option, squash the PR manually or land the PR from the command line.

https://github.com/nodejs/node/actions/runs/1763130093

@nodejs-github-bot nodejs-github-bot added the commit-queue-failed An error occurred while landing this pull request using GitHub Actions. label Jan 28, 2022
@benjamingr benjamingr added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. and removed commit-queue-failed An error occurred while landing this pull request using GitHub Actions. labels Jan 28, 2022
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Jan 28, 2022
@nodejs-github-bot nodejs-github-bot merged commit 64c4b55 into nodejs:master Jan 28, 2022
@nodejs-github-bot
Copy link
Collaborator

Landed in 64c4b55

@benjamingr benjamingr deleted the unhandled-rejection-cross-realm-stack branch January 29, 2022 17:17
Linkgoron pushed a commit to Linkgoron/node that referenced this pull request Jan 31, 2022
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>
ruyadorno pushed a commit that referenced this pull request Feb 8, 2022
Support cross realm errors where `instanceof` errors in our
unhandledRejection warning to print better error with stack traces.

PR-URL: #41682
Refs: #41676
Reviewed-By: Nitzan Uziely <linkgoron@gmail.com>
Reviewed-By: Tierney Cyren <hello@bnb.im>
danielleadams pushed a commit that referenced this pull request Mar 2, 2022
Support cross realm errors where `instanceof` errors in our
unhandledRejection warning to print better error with stack traces.

PR-URL: #41682
Refs: #41676
Reviewed-By: Nitzan Uziely <linkgoron@gmail.com>
Reviewed-By: Tierney Cyren <hello@bnb.im>
danielleadams pushed a commit that referenced this pull request Mar 3, 2022
Support cross realm errors where `instanceof` errors in our
unhandledRejection warning to print better error with stack traces.

PR-URL: #41682
Refs: #41676
Reviewed-By: Nitzan Uziely <linkgoron@gmail.com>
Reviewed-By: Tierney Cyren <hello@bnb.im>
danielleadams pushed a commit that referenced this pull request Mar 14, 2022
Support cross realm errors where `instanceof` errors in our
unhandledRejection warning to print better error with stack traces.

PR-URL: #41682
Refs: #41676
Reviewed-By: Nitzan Uziely <linkgoron@gmail.com>
Reviewed-By: Tierney Cyren <hello@bnb.im>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. errors Issues and PRs related to JavaScript errors originated in Node.js core. needs-ci PRs that need a full CI run. process Issues and PRs related to the process subsystem. promises Issues and PRs related to ECMAScript promises.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants