Skip to content

v8: preserve DOMException in v8.serialize() - #67697

Draft
jazelly wants to merge 1 commit into
nodejs:mainfrom
jazelly:fix-53225
Draft

jazelly wants to merge 1 commit into
nodejs:mainfrom
jazelly:fix-53225

Conversation

@jazelly

@jazelly jazelly commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Fixes: #53225

v8.serialize() turns a DOMException into a plain Error with an empty message. structuredClone() already handles it.

v8.deserialize(v8.serialize(AbortSignal.abort().reason));
// before: Error {}  after: DOMException [AbortError]: This operation was aborted

SerializerContext now implements IsHostObject(), so DefaultSerializer writes cloneable DOMExceptions using the existing clone hooks (same data as structuredClone()). Plain v8.Serializer is unchanged.

child_process with serialization: 'advanced' uses node_ipc_serdes.cc and is not covered here.

`DOMException` is a native error whose name and message are kept in
internal state, so V8's built-in error serialization turned it into a
plain `Error` with an empty message when using `v8.serialize()`.
`structuredClone()` already handled it via the host object delegate.

Let `DefaultSerializer` treat cloneable native errors as host objects
and serialize them following the WebIDL `DOMException` serialization
steps (name, message, stack, plus quota/requested for
`QuotaExceededError`), carrying the same data as `structuredClone()`.
Plain `v8.Serializer` instances keep their previous behavior.

Fixes: nodejs#53225
Assisted-by: Claude Opus 5.5
Signed-off-by: jazelly <xzha4350@gmail.com>
@nodejs-github-bot nodejs-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. v8 module Issues and PRs related to the node:v8 module. labels Nov 22, 2026
Sign up for free to 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++. needs-ci PRs that need a full CI run. v8 module Issues and PRs related to the node:v8 module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DOMExceptions do not work with v8.serialize()

2 participants