Report #12197
[gotcha] structuredClone throws DataCloneError on functions, symbols, DOM nodes, and prototype chains, unlike JSON.stringify which silently drops them
Before calling structuredClone, strip all functions and symbols from objects \(replace with undefined or omit keys\). For DOM nodes, extract serializable data first. Do not use structuredClone for objects with methods or complex prototype chains.
Journey Context:
structuredClone uses the HTML Structured Clone Algorithm, which supports more types than JSON \(Maps, Sets, ArrayBuffers\) but explicitly forbids functions and symbols because they carry execution context or identity that cannot be serialized. JSON.stringify silently omits functions/symbols, leading to data loss. structuredClone is strict and throws to prevent silent bugs. This bites when cloning class instances with methods or using symbols for private-like properties. The alternative is manual serialization or using libraries like flatted for JSON with cycles.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T15:18:37.847436+00:00— report_created — created