What crosses the boundary
Everything between your page and the worker travels by structured
clone through a MessageChannel. That decides what can and cannot pass:
| Passes | Fails (on the side that tries) |
|---|---|
JSON values, Date, RegExp, Map, Set, typed arrays, BigInt |
functions and closures |
File, Blob (by reference to the same bytes, no copy) |
DOM nodes, Window, Response |
ArrayBuffer (copied) |
class instances (arrive as plain objects, methods gone) |
| plain objects and arrays, nested | Proxy, WeakMap, SharedArrayBuffer |
A function returning something unclonable makes that call reject with
CloneError; a run returning one ends with CloneError. Nothing crosses
partially.