Skip to content

lib: make domexception a native error #58691

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

Closed
wants to merge 2 commits into from

Conversation

legendecas
Copy link
Member

@legendecas legendecas commented Jun 12, 2025

deps: V8: cherry-pick e3df60f3f5ab

Original commit message:

[objects] allow host defined serializer of JSError

Allow host defined serializer and deserializer of JSError in
ValueSerializer API. This allows hosts that implement DOMException
in JS to support `Error.isError` proposal and `structuredClone`.

Refs: https://github.com/nodejs/node/pull/58691
Change-Id: I022821c9abd659970c4d449b3c69c5fb54d0618a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6637876
Reviewed-by: Camillo Bruni <cbruni@chromium.org>
Commit-Queue: Chengzhong Wu <cwu631@bloomberg.net>
Cr-Commit-Position: refs/heads/main@{#100894}

Refs: v8/v8@e3df60f

lib: make domexception a native error

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

IsJSErrorMap(obj_map) ||
(IsJSApiWrapperObjectMap(obj_map) &&
isolate->IsJSApiWrapperNativeError(Cast<JSReceiver>(obj))));

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: #58138
Fixes: #56497

@nodejs-github-bot
Copy link
Collaborator

nodejs-github-bot commented Jun 12, 2025

Review requested:

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

@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Jun 12, 2025
@legendecas legendecas marked this pull request as draft June 12, 2025 10:51
Copy link

codecov bot commented Jun 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.10%. Comparing base (5584cc5) to head (27dfaaa).
Report is 15 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%) ⬆️

... and 41 files with indirect coverage changes

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

@legendecas
Copy link
Member Author

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

@legendecas legendecas force-pushed the dom-exception-iserror branch 2 times, most recently from 40c22d3 to b8d3f25 Compare June 12, 2025 16:46
hubot pushed a commit to v8/v8 that referenced this pull request Jun 18, 2025
Allow host defined serializer and deserializer of JSError in
ValueSerializer API. This allows hosts that implement DOMException
in JS to support `Error.isError` proposal and `structuredClone`.

Refs: nodejs/node#58691
Change-Id: I022821c9abd659970c4d449b3c69c5fb54d0618a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6637876
Reviewed-by: Camillo Bruni <cbruni@chromium.org>
Commit-Queue: Chengzhong Wu <cwu631@bloomberg.net>
Cr-Commit-Position: refs/heads/main@{#100894}
legendecas and others added 2 commits June 19, 2025 11:54
Original commit message:

    [objects] allow host defined serializer of JSError

    Allow host defined serializer and deserializer of JSError in
    ValueSerializer API. This allows hosts that implement DOMException
    in JS to support `Error.isError` proposal and `structuredClone`.

    Refs: nodejs#58691
    Change-Id: I022821c9abd659970c4d449b3c69c5fb54d0618a
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6637876
    Reviewed-by: Camillo Bruni <cbruni@chromium.org>
    Commit-Queue: Chengzhong Wu <cwu631@bloomberg.net>
    Cr-Commit-Position: refs/heads/main@{#100894}

Refs: v8/v8@e3df60f
Co-Authored-By: Kenta Moriuchi <moriken@kimamass.com>
@legendecas legendecas force-pushed the dom-exception-iserror branch from b8d3f25 to 27dfaaa Compare June 19, 2025 10:57
@legendecas legendecas marked this pull request as ready for review June 19, 2025 10:57
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

Copy link
Member

@jazelly jazelly left a comment

Choose a reason for hiding this comment

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

was following this. lgtm

@legendecas legendecas added commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. author ready PRs that have at least one approval, no pending requests for changes, and a CI started. labels Jun 20, 2025
@nodejs-github-bot
Copy link
Collaborator

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@nodejs-github-bot
Copy link
Collaborator

@legendecas legendecas added the commit-queue Add this label to land a pull request using GitHub Actions. label Jun 21, 2025
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Jun 21, 2025
@nodejs-github-bot
Copy link
Collaborator

Landed in 11222f1...e679e38

nodejs-github-bot pushed a commit that referenced this pull request Jun 21, 2025
Original commit message:

    [objects] allow host defined serializer of JSError

    Allow host defined serializer and deserializer of JSError in
    ValueSerializer API. This allows hosts that implement DOMException
    in JS to support `Error.isError` proposal and `structuredClone`.

    Refs: #58691
    Change-Id: I022821c9abd659970c4d449b3c69c5fb54d0618a
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6637876
    Reviewed-by: Camillo Bruni <cbruni@chromium.org>
    Commit-Queue: Chengzhong Wu <cwu631@bloomberg.net>
    Cr-Commit-Position: refs/heads/main@{#100894}

Refs: v8/v8@e3df60f
PR-URL: #58691
Fixes: #56497
Refs: #58138
Reviewed-By: Jason Zhang <xzha4350@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: James M Snell <jasnell@gmail.com>
nodejs-github-bot pushed a commit that referenced this pull request Jun 21, 2025
Co-Authored-By: Kenta Moriuchi <moriken@kimamass.com>
PR-URL: #58691
Fixes: #56497
Refs: v8/v8@e3df60f
Refs: #58138
Reviewed-By: Jason Zhang <xzha4350@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: James M Snell <jasnell@gmail.com>
@legendecas legendecas deleted the dom-exception-iserror branch June 21, 2025 10:53
@alexsch01
Copy link
Contributor

alexsch01 commented Jun 21, 2025

Would this qualify for a backport in NodeJS 24?

RafaelGSS pushed a commit that referenced this pull request Jun 23, 2025
Original commit message:

    [objects] allow host defined serializer of JSError

    Allow host defined serializer and deserializer of JSError in
    ValueSerializer API. This allows hosts that implement DOMException
    in JS to support `Error.isError` proposal and `structuredClone`.

    Refs: #58691
    Change-Id: I022821c9abd659970c4d449b3c69c5fb54d0618a
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6637876
    Reviewed-by: Camillo Bruni <cbruni@chromium.org>
    Commit-Queue: Chengzhong Wu <cwu631@bloomberg.net>
    Cr-Commit-Position: refs/heads/main@{#100894}

Refs: v8/v8@e3df60f
PR-URL: #58691
Fixes: #56497
Refs: #58138
Reviewed-By: Jason Zhang <xzha4350@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: James M Snell <jasnell@gmail.com>
RafaelGSS pushed a commit that referenced this pull request Jun 23, 2025
Co-Authored-By: Kenta Moriuchi <moriken@kimamass.com>
PR-URL: #58691
Fixes: #56497
Refs: v8/v8@e3df60f
Refs: #58138
Reviewed-By: Jason Zhang <xzha4350@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: James M Snell <jasnell@gmail.com>
zloirock added a commit to zloirock/core-js that referenced this pull request Jun 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DOMException should have [[ErrorData]] internal slot
9 participants