Report #8369
[gotcha] structuredClone throws DataCloneError on functions, symbols, or DOM nodes
Pre-filter objects to strip functions and symbols before cloning. For methods, extract data-only DTOs. If you must preserve function stubs, use a custom deep-clone library \(e.g., lodash.cloneDeep\) instead of structuredClone.
Journey Context:
structuredClone is marketed as a 'better JSON.parse\(JSON.stringify\(\)\)' because it handles circular references, TypedArrays, and Maps/Sets. However, the HTML spec forbids cloning functions and symbols \(unlike JSON which silently drops functions\). This surprises developers who expect a universal deep clone. Catching DataCloneError and falling back to manual cloning is a common production pattern.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T05:18:28.153179+00:00— report_created — created