| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. ❤️ ShareComment @coderabbitai help to get the list of available commands. |
Sorry, something went wrong.
The dom-exception builtin gains a native half: markCloneable stamps every instance with a per-isolate private brand (Caches::StateFor), and the serialization delegates claim branded objects through V8's HasCustomHostObject/IsHostObject hooks — the same escape hatch Node's JSTransferable protocol uses, reduced to the one class. The payload (name, message, stack) travels out-of-band on the SerializedValue with only a tag and index in the stream, because V8 forbids JS execution while a value is being read: Deserialize constructs every instance through the real constructor before ReadValue starts — on a worker isolate that never touched DOMException that runs the builtin on demand — and ReadHostObject hands them out by index, Node's host_objects_ design. Rebuilding through the constructor re-brands the instance, so a forwarded exception serializes again on the next hop. The degraded-wrapper path now writes an explicit tag where it wrote nothing; the bytes never outlive the process, so the format is free to change with the file. DOMException serializes under both host-object policies: structuredClone's kReject only refuses objects with a native half to lose, and a DOMException has none. Cost of the claim: with HasCustomHostObject on, V8 asks IsHostObject about every plain JS object in a graph — one private-symbol lookup each, the price Node pays for the same protocol.
HasCustomHostObject makes V8 consult IsHostObject for every plain JS object in a serialized graph — measured ~25ns each, ~+12% on an object-heavy structuredClone. An isolate that never constructed a DOMException cannot be holding one, so the claim is gated on a per-isolate flag markCloneable flips with the first instance; until then serialization runs the pre-claim path untouched. Accepted edge, documented at the sample site: a getter running during the very clone could construct the isolate's first DOMException after a false sample — that one instance degrades to a plain object, the pre-feature behavior, and every later serialization sees the flag.
| Back | FazBrowse Home | New Git URL |
Stacked on #452. Implements the [Serializable] slot that PR deliberately left out, so DOMException survives structuredClone and worker postMessage instead of degrading like a custom Error subclass.
Mechanism (Node's JSTransferable protocol, reduced to one class)
Tests
Benchmarks
structuredClone medians, iPad Pro simulator, 12 runs after warmup (temporary in-suite benchmark, not committed). "Claim off" is an isolate that has never constructed a DOMException — the gated HasCustomHostObject (second commit) keeps it on the exact pre-change path; "claim on" is after the first instance exists.
Claim-off vs base differences are run-to-run noise. So: zero cost for apps that never touch DOMException, ~25ns per plain object on serialization-heavy paths afterward — the price Node pays unconditionally. Accepted edge (documented in-source): a getter constructing the isolate's first DOMException during the very clone that contains it degrades that one instance to a plain object.