Commit 84fc2b6
committed
feat: serialize DOMException per Web IDL [Serializable]
DOMException carries the [Serializable] slot in Web IDL, so it must survive
structuredClone and worker postMessage rather than degrading the way a custom
Error subclass does. Node reaches that with its JSTransferable protocol; this
is the same mechanism reduced to the one class.
The dom-exception builtin gains a native half: binding.markCloneable stamps
every instance with a per-isolate v8::Private held in the runtime's
RuntimeState, unforgeable and invisible from JS. Every GetExports call site for
that builtin now goes through serialization::GetDomExceptionExports, because
GetExports consults the binding factory only on the run that populates the
cache.
The serializer delegate claims host objects unconditionally and answers
IsHostObject from the brand. That claim replaces V8's own embedder-field
detection instead of extending it, so objects with internal fields — Java
proxies, URL, URLSearchParams, ObjectManager wrappers — are claimed first and
keep their existing behavior: a DataCloneError under structuredClone, an empty
object over postMessage.
V8 forbids JS execution while a value is being read, so the payload travels
out-of-band: WriteHostObject pushes {name, message, stack} onto the
SerializedValue and writes a tag plus an index, and Deserialize constructs every
instance through the real constructor before ReadValue starts — running the
builtin on demand on a worker isolate that never touched DOMException.
Construction re-brands, so a forwarded exception serializes on the next hop.
Host objects now start with a uint32 tag (0 = degraded native wrapper, 1 =
DOMException index); the bytes never outlive the process.1 parent 0ffff1b commit 84fc2b6
10 files changed
Lines changed: 361 additions & 29 deletions
File tree
- docs
- test-app
- app/src/main/assets/app
- tests
- runtime/src/main/cpp
- js
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
- BroadcastChannel/BroadcastWorker.js+27
- BroadcastChannel/index.js+343
- DOMException/index.js+53
- MessageChannel/index.js+762
- MessageEvent/index.js+299
- NodeWorkerThreads/ThreadWorker.js+49
- NodeWorkerThreads/index.js+656
- WorkerEvents/PortWorker.js+22
- WorkerEvents/ScopeEventsWorker.js+28
- WorkerEvents/ThrowingWorker.js+7
- WorkerEvents/index.js+293
- Workers/index.js+53-1
- index.js+25
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
Lines changed: 41 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
65 | 106 | | |
66 | 107 | | |
67 | 108 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
41 | | - | |
| 42 | + | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
61 | | - | |
| 62 | + | |
| 63 | + | |
62 | 64 | | |
63 | 65 | | |
64 | 66 | | |
| |||
0 commit comments