Report #59457
[gotcha] structuredClone throws DataCloneError on functions, symbols, or DOM nodes
Strip functions and symbols before cloning, or catch DataCloneError. For complex objects, implement a custom replacer that removes non-serializable properties.
Journey Context:
structuredClone implements the HTML Structured Clone Algorithm, which can handle Maps, Sets, and ArrayBuffers but explicitly forbids functions, symbols, and host objects like DOM nodes. Attempting to clone these throws a DataCloneError \(DOMException\). This differs from JSON.stringify which silently strips them. The error is thrown synchronously at the call site, making it a hard failure in data persistence code.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T06:17:26.025927+00:00— report_created — created