Report #15396
[gotcha] structuredClone silently strips functions, DOM nodes, and prototype chains from cloned objects
Use structuredClone only for plain data transfer \(postMessage, IndexedDB\); for class instances with methods, manually reconstruct after cloning or use a serialization library that supports class revival \(e.g., devalue\).
Journey Context:
structuredClone was introduced as a deep clone solution supporting circular references, Maps, Sets, and TypedArrays. However, it follows the HTML structured serialize algorithm, which explicitly throws DataCloneError for functions and DOM nodes, and clones objects by copying enumerable own properties while discarding the prototype chain. Passing a class instance results in a plain Object on the other side, breaking method calls. Developers migrating from lodash's cloneDeep \(which preserves methods by reference\) or expecting to clone event handlers encounter runtime 'is not a function' errors.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T23:54:59.333003+00:00— report_created — created