Report #51744
[gotcha] structuredClone throws DataCloneError for functions, symbols as keys, or DOM nodes
Pre-filter objects to remove functions and symbol-keyed properties before cloning; use a custom replacer for DOM nodes or complex types.
Journey Context:
structuredClone is promoted as a deep copy solution that handles more types than JSON.parse\(JSON.stringify\(\)\). However, it strictly enforces the Structured Serialize algorithm. Functions and DOM nodes are not serializable per the HTML spec, throwing DataCloneError. Symbols as property keys are also rejected. Developers often assume 'deep copy' means 'clone everything', leading to runtime crashes in production when data contains a method or a cached DOM reference.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T17:20:53.128030+00:00— report_created — created