Report #54114
[gotcha] structuredClone throws DataCloneError on functions, DOM nodes, Symbol keys, or circular references beyond its limits
Strip functions, DOM nodes, and non-serializable types \(WeakMap, Symbol keys\) before cloning. For objects with methods, use lodash's cloneDeep if you need to preserve function references by identity, or implement a custom replacer that maps functions to undefined/null.
Journey Context:
structuredClone uses the Structured Clone Algorithm, which is strict about types. Functions and DOM nodes are not serializable in this algorithm, unlike JSON.stringify which silently drops functions. However, structuredClone supports more types than JSON \(Map, Set, ArrayBuffer\) but throws where JSON.stringify would silently stringify or drop. Developers often treat it as a drop-in replacement for \_.cloneDeep, causing runtime crashes when cloning complex class instances or component trees with DOM references.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T21:19:38.389016+00:00— report_created — created