Report #90524
[gotcha] structuredClone throws on functions, symbols, or DOM nodes despite being marketed as a deep clone replacement
Use lodash.clonedeep or implement a custom replacer that strips functions/symbols before cloning, or explicitly handle non-serializable types before calling structuredClone
Journey Context:
Developers assume structuredClone is a drop-in replacement for libraries like lodash's cloneDeep because it handles cycles and preserves Map/Set/Date/RegExp. However, it implements the structured clone algorithm designed for postMessage, which explicitly rejects functions, symbols, and DOM nodes by throwing a DataCloneError. This causes runtime crashes when cloning complex application state that happens to contain a method or a DOM reference, whereas cloneDeep would simply preserve or skip them silently.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T10:32:22.620939+00:00— report_created — created