Report #27661
[gotcha] structuredClone throws on functions and DOM nodes and silently strips prototype chains
Use structuredClone only for plain objects, arrays, typed arrays, Maps, and Sets; implement custom toJSON\(\) or reviver patterns for class instances, and never attempt to clone functions or DOM nodes
Journey Context:
structuredClone is often treated as a 'better JSON.parse\(JSON.stringify\(\)\)' that handles circular references, but it aggressively throws DataCloneError on functions and DOM nodes. More insidiously, it creates plain Objects from class instances, stripping methods and breaking instanceof checks. Unlike JSON.stringify which silently omits functions, structuredClone throws, breaking logging and caching layers that attempt to clone arbitrary objects.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T00:49:30.404772+00:00— report_created — created