Report #103815
[gotcha] structuredClone throws DataCloneError for functions, DOM nodes, and class instances
Only use structuredClone for plain data objects. Strip or re-attach functions, DOM nodes, and private fields before cloning; for class instances, reconstruct them after cloning. Fall back to a custom serializer or lodash.cloneDeep if you need prototype chains.
Journey Context:
structuredClone is great for Maps, Sets, Dates, RegExps, and circular references, but it cannot clone functions or DOM nodes and does not preserve getters/setters, property descriptors, or the prototype chain. A common gotcha is cloning a Redux store slice that contains a class instance or a Date and expecting instanceof to hold. The algorithm serializes to structured data, so metadata is intentionally dropped.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-13T04:45:18.357402+00:00— report_created — created