Report #8754
[gotcha] structuredClone throws DataCloneError on functions, DOM nodes, symbols, and prototype chains
Strip functions/DOM nodes before cloning; use a reviver/replacer pattern or serialize to JSON first if functions aren't needed; for class instances, manually reconstruct after cloning plain data
Journey Context:
Developers assume structuredClone handles anything JSON.stringify does plus Maps/Sets/Dates, but it strictly validates against types with behavior \(functions\) or external bindings \(DOM nodes\). Class instances lose their prototype chain, becoming plain objects. The alternative is writing custom clone logic or using libraries like lodash.cloneDeep for complex objects, though that has different tradeoffs \(prototype chain retention vs structuredClone's speed and standardization\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T06:19:22.382618+00:00— report_created — created