node icon indicating copy to clipboard operation
node copied to clipboard

lib: make domexception a native error

Open legendecas opened this issue 6 months ago • 3 comments

isolate->SetJSApiWrapperNativeErrorCallback(IsNodeError) can not be used because V8 only invokes the callback for native objects:

https://github.com/nodejs/node/blob/708477bd8d68f3571b02bb311dccc3d892e447d1/deps/v8/src/builtins/builtins-error.cc#L72-L74

Setting this callback also requires embedders like electron to decide if they need to override blink's callback. So it is simpler to implement this in JS only.

Refs: https://github.com/nodejs/node/pull/58138 Fixes: https://github.com/nodejs/node/issues/56497

legendecas avatar Jun 12 '25 10:06 legendecas

Review requested:

  • [ ] @nodejs/web-standards
  • [ ] @nodejs/v8-update
  • [ ] @nodejs/gyp

nodejs-github-bot avatar Jun 12 '25 10:06 nodejs-github-bot

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 90.10%. Comparing base (5584cc5) to head (27dfaaa). :warning: Report is 636 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #58691      +/-   ##
==========================================
- Coverage   90.13%   90.10%   -0.04%     
==========================================
  Files         639      639              
  Lines      188192   188209      +17     
  Branches    36916    36906      -10     
==========================================
- Hits       169633   169580      -53     
- Misses      11324    11369      +45     
- Partials     7235     7260      +25     
Files with missing lines Coverage Δ
lib/internal/per_context/domexception.js 82.43% <100.00%> (+1.58%) :arrow_up:

... and 41 files with indirect coverage changes

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Jun 12 '25 11:06 codecov[bot]

Fixing structuredClone support in https://chromium-review.googlesource.com/c/v8/v8/+/6637876.

legendecas avatar Jun 12 '25 12:06 legendecas

CI: https://ci.nodejs.org/job/node-test-pull-request/67528/

nodejs-github-bot avatar Jun 19 '25 10:06 nodejs-github-bot

V8 CI: https://ci.nodejs.org/job/node-test-commit-v8-linux/nodes=benchmark-ubuntu2204-intel-64,v8test=v8test/6618/

nodejs-github-bot avatar Jun 19 '25 12:06 nodejs-github-bot

V8 CI: https://ci.nodejs.org/job/node-test-commit-v8-linux/nodes=rhel8-ppc64le,v8test=v8test/6618/

nodejs-github-bot avatar Jun 19 '25 12:06 nodejs-github-bot

V8 CI: https://ci.nodejs.org/job/node-test-commit-v8-linux/nodes=rhel8-s390x,v8test=v8test/6618/

nodejs-github-bot avatar Jun 19 '25 12:06 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/67542/

nodejs-github-bot avatar Jun 19 '25 20:06 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/67560/

nodejs-github-bot avatar Jun 20 '25 10:06 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/67566/

nodejs-github-bot avatar Jun 20 '25 12:06 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/67572/

nodejs-github-bot avatar Jun 20 '25 15:06 nodejs-github-bot

Landed in 11222f1a272b9b2ab000e75cbe3e09942bd2d877...e679e38b252ee5203ef583392f77fd532e2b4a67

nodejs-github-bot avatar Jun 21 '25 10:06 nodejs-github-bot

Would this qualify for a backport in NodeJS 24?

alexsch01 avatar Jun 21 '25 11:06 alexsch01

We're getting a test failure with this change on v22.x-staging:

=== release test-structuredClone-domexception ===                   
Path: parallel/test-structuredClone-domexception
node:assert:95
  throw new AssertionError(obj);
  ^

AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:

false !== true

    at assertDOMException (…/test/parallel/test-structuredClone-domexception.js:7:10)
    at Object.<anonymous> (…/test/parallel/test-structuredClone-domexception.js:19:3)
    at Module._compile (node:internal/modules/cjs/loader:1688:14)

https://github.com/nodejs/node/blob/54574432109f353dcb936343d732f406584bce51/test/parallel/test-structuredClone-domexception.js#L7

aduh95 avatar Jul 21 '25 17:07 aduh95

Backport open at https://github.com/nodejs/node/pull/59957.

legendecas avatar Sep 21 '25 14:09 legendecas