-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Closed
Labels
feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.stale
Description
Currently, custom error objects implemented in JavaScript are not cloneable via postMessage / structuredClone with perfect fidelity.
e.g.
const d = new DOMException('foo', 'AbortErr');
const mc = new MessageChannel();
mc.port1.onmessage = ({data}) => {
console.log(data is DOMException); // false
console.log(data.name); // AbortErr
console.log(data.message); // 'foo'
console.log(data.code); // undefined
};
mc.port1.postMessage(d);Likewise, AbortError is also not correctly cloneable.
The current way that DOMException is implemented (in JavaScript during the per_context bootstrap), it is not possible for us to use the existing internal/worker/js_transferable mechanisms to make it cloneable as the DOMException is loaded too early.
However, if we reimplement DOMException as a native host object (within a C++ binding extending BaseObject) then we can easily make it cloneable (likewise with AbortError). Before going through that effort, however, I wanted to see what folks thought.
hello-smile6
Metadata
Metadata
Assignees
Labels
feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.stale