`DOMException`s do not work with `v8.serialize()`
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 122k
- Forks
- 37.3k
- Avg merge
- 4d 2h
- Merged PRs (30d)
- 283
Description
Version
v22.1.0
Platform
Linux ether-laptop 6.5.0-35-generic #35-Ubuntu SMP PREEMPT_DYNAMIC Fri Apr 26 11:23:57 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
node:v8
What steps will reproduce the bug?
import {serialize, deserialize} from 'node:v8';
const error = AbortSignal.abort().reason;
console.log(error instanceof DOMException);
// true
console.log(error);
// DOMException [AbortError]: This operation was aborted
// at new DOMException (node:internal/per_context/domexception:53:5)
// at AbortSignal.abort (node:internal/abort_controller:205:14)
// at ...
const clonedError = deserialize(serialize(error));
console.log(clonedError instanceof DOMException);
// false
console.log(clonedError);
// {}
How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior? Why is that the expected behavior?
A DOMException should be serializable/deserializable like other error instances.
What do you see instead?
Serializing/deserializing with v8 turns it into an empty plain object.
Additional information
Related: structuredClone(domException) returns an empty plain object, which is probably the same bug. This might be related to #49181.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The report targets node:v8 serialize/deserialize and reproduces the issue with AbortSignal.abort().reason; start by tracing that round trip and comparing it with other Error instances. Done means DOMException survives serialization as a DOMException with its observable data preserved, with a regression test covering the reported example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100