Report #94252
[gotcha] structuredClone throws on functions and DOM nodes, and silently strips prototype chains and non-serializable properties
Before cloning, explicitly strip functions and DOM references; for class instances, accept that output will be plain objects or implement custom serialization using the 'transfer' option with a library like devalue or flatted for complex graphs
Journey Context:
Developers assume structuredClone is a 'perfect deep clone' like lodash.cloneDeep, but the HTML spec explicitly forbids functions and DOM nodes because they contain execution context or C\+\+ backing objects that cannot be serialized across realms. Prototype chains are also flattened to Object.prototype, and getters/setters are evaluated and lost. This breaks class instances \(methods disappear\) and any object containing closures. The clone is safe for structured data \(JSON-like\) but dangerous for rich objects.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T16:47:18.285889+00:00— report_created — created