Skip to content

node-api: return napi_exception_pending on throwing proxy handlers - #48607

Closed
legendecas wants to merge 1 commit into
nodejs:mainfrom
legendecas:node-api/define-property
Closed

node-api: return napi_exception_pending on throwing proxy handlers#48607
legendecas wants to merge 1 commit into
nodejs:mainfrom
legendecas:node-api/define-property

Conversation

@legendecas

Copy link
Copy Markdown
Member

Accessing JS objects can be trapped with proxy handlers. These
handlers can throw when no node-api errors occur. In such cases,
napi_pending_exception should be returned.

Refs: #48440 (comment)

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/gyp
  • @nodejs/node-api

@nodejs-github-botnodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. node-api Issues and PRs related to the Node-API. labels Jun 30, 2023
@legendecas
legendecasforce-pushed the node-api/define-property branch 2 times, most recently from e899363 to 3b3bc46CompareJune 30, 2023 05:50
@mhdawson

Copy link
Copy Markdown
Member

We discussed in the meeting today. We already have some similar callsites which are returning the exception correctly and therefore should already be handling the way the status code will be returned after the update.

@legendecas suggested that we run CITGM as well to gather some more info.

Comment threadtest/js-native-api/test_object/test_exceptions.c Outdated
Comment threadtest/js-native-api/test_object/test_exceptions.c Outdated

@gabrielschulhofgabrielschulhof left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor suggestion.

@legendecaslegendecas added the request-ci Add this label to start a Jenkins CI on a PR. label Jul 28, 2023
@github-actionsgithub-actionsBot added request-ci-failed An error occurred while starting CI via request-ci label, and manual interventon is needed. and removed request-ci Add this label to start a Jenkins CI on a PR. labels Jul 28, 2023
@github-actions

Copy link
Copy Markdown
Contributor
Failed to start CI
- Validating Jenkins credentials
✔ Jenkins credentials valid
- Starting PR CI job
✘ Failed to start PR CI: 200 OK
https://github.com/nodejs/node/actions/runs/5689928114

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@legendecaslegendecas removed the request-ci-failed An error occurred while starting CI via request-ci label, and manual interventon is needed. label Jul 31, 2023
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@mhdawsonmhdawson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mhdawsonmhdawson added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 23, 2023
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 23, 2023
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@legendecaslegendecas added request-ci Add this label to start a Jenkins CI on a PR. and removed request-ci Add this label to start a Jenkins CI on a PR. labels Sep 15, 2023
@aduh95

Copy link
Copy Markdown
Contributor

Seemingly related test failure:

not ok 3802 js-native-api/test_object/test_exceptions
---
duration_ms: 718.38600
severity: crashed
exitcode: -5
stack: |-
#
# Fatal error in ../deps/v8/src/ic/ic.cc, line 2690
# Debug check failed: !__isolate__->has_pending_exception().
#
#
#
#FailureMessage Object: 0xffffc7888778
1: 0xaaaaea9d09a0 node::DumpBacktrace(_IO_FILE*) [out/Debug/node]
2: 0xaaaaeabb6b04 [out/Debug/node]
3: 0xaaaaeabb6b30 [out/Debug/node]
4: 0xaaaaec90a7b8 V8_Fatal(char const*, int, char const*, ...) [out/Debug/node]
5: 0xaaaaec90a7e0 V8_Dcheck(char const*, int, char const*) [out/Debug/node]
6: 0xaaaaeb3eb978 v8::internal::Runtime_LoadNoFeedbackIC_Miss(int, unsigned long*, v8::internal::Isolate*) [out/Debug/node]
7: 0xaaaaebf8c3e4 [out/Debug/node]
...

@legendecas

Copy link
Copy Markdown
MemberAuthor

Yes, I'm trying to reproduce it locally with an arm Linux setup.

@legendecas

Copy link
Copy Markdown
MemberAuthor

The debug test failure is caused by the fact that v8::Object::DefineProperty didn't clear the pending exception and v8::internal::Isolate::has_pending_exception() still returned true after the v8 API call returned. This can be fixed by https://chromium-review.googlesource.com/c/v8/v8/+/4594617.

The problem can happen whenever v8::Object::DefineProperty is called on a throwing JSProxy trap handler and invokes another V8 API (but only crashes on debug build).

Accessing JS objects can be trapped with proxy handlers. These
handlers can throw when no node-api errors occur. In such cases,
`napi_pending_exception` should be returned.
@legendecas
legendecasforce-pushed the node-api/define-property branch from 4b74fa5 to a4f2dbfCompareOctober 12, 2023 10:01
@legendecaslegendecas added the request-ci Add this label to start a Jenkins CI on a PR. label Oct 12, 2023
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Oct 12, 2023
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@legendecas

Copy link
Copy Markdown
MemberAuthor

@nodejs/node-api CI has passed. Would you mind taking a look at this again? Thank you!

@legendecas

Copy link
Copy Markdown
MemberAuthor

As discussed at node-api meeting Oct 20, the change is essentially a clean rebase so I'm going to land this.

This depends on 17a74dd which is included in v21.x.

@legendecaslegendecas added the commit-queue Add this label to land a pull request using GitHub Actions. label Oct 23, 2023
@nodejs-github-botnodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Oct 23, 2023
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator
Commit Queue failed
- Loading data for nodejs/node/pull/48607
✔ Done loading data for nodejs/node/pull/48607
----------------------------------- PR info ------------------------------------
Title node-api: return napi_exception_pending on throwing proxy handlers (#48607)
⚠ Could not retrieve the email or name of the PR author's from user's GitHub profile!
Branch legendecas:node-api/define-property -> nodejs:main
Labels c++, node-api, needs-ci, dont-land-on-v18.x, dont-land-on-v20.x
Commits 1
- node-api: return napi_exception_pending on proxy handlers
Committers 1
- Chengzhong Wu PR-URL: https://github.com/nodejs/node/pull/48607
Reviewed-By: Gabriel Schulhof Reviewed-By: Michael Dawson ------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/48607
Reviewed-By: Gabriel Schulhof Reviewed-By: Michael Dawson --------------------------------------------------------------------------------
⚠ Commits were pushed since the last approving review:
⚠ - node-api: return napi_exception_pending on proxy handlers
ℹ This PR was created on Fri, 30 Jun 2023 03:51:49 GMT
✔ Approvals: 2
✔ - Gabriel Schulhof (@gabrielschulhof): https://github.com/nodejs/node/pull/48607#pullrequestreview-1584729738
✔ - Michael Dawson (@mhdawson) (TSC): https://github.com/nodejs/node/pull/48607#pullrequestreview-1592156805
✔ Last GitHub CI successful
ℹ Last Full PR CI on 2023-10-17T15:54:31Z: https://ci.nodejs.org/job/node-test-pull-request/54888/
- Querying data for job/node-test-pull-request/54888/
✔ Last Jenkins CI successful
--------------------------------------------------------------------------------
✔ Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/6610202932

@mhdawson

Copy link
Copy Markdown
Member

Landed in 52fcf14

mhdawson pushed a commit that referenced this pull request Oct 23, 2023
Accessing JS objects can be trapped with proxy handlers. These
handlers can throw when no node-api errors occur. In such cases,
`napi_pending_exception` should be returned.
PR-URL: #48607
Reviewed-By: Gabriel Schulhof <gabrielschulhof@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
@legendecas
legendecas deleted the node-api/define-property branch October 24, 2023 06:55
targos pushed a commit that referenced this pull request Oct 24, 2023
Accessing JS objects can be trapped with proxy handlers. These
handlers can throw when no node-api errors occur. In such cases,
`napi_pending_exception` should be returned.
PR-URL: #48607
Reviewed-By: Gabriel Schulhof <gabrielschulhof@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
@targostargos mentioned this pull request Oct 24, 2023
@marco-ippolitomarco-ippolito mentioned this pull request Mar 6, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++Issues and PRs that require attention from people who are familiar with C++.commit-queue-failedAn error occurred while landing this pull request using GitHub Actions.needs-ciPRs that need a full CI run.node-apiIssues and PRs related to the Node-API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@legendecas@nodejs-github-bot@mhdawson@richardlau@gabrielschulhof@aduh95