Report #46953
[gotcha] structuredClone throws DataCloneError on functions/symbols while JSON.stringify silently omits them
Pre-filter objects to remove non-serializable values \(functions, symbols, DOM nodes\) before structuredClone; do not use structuredClone as a drop-in replacement for JSON.stringify without handling the strictness difference
Journey Context:
structuredClone preserves types \(Map, Set, typed arrays, circular refs\) but is strict \(throws DataCloneError on non-serializable types\), whereas JSON.stringify is lossy and silent. Passing Vue/React component instances, bound functions, or symbols to workers/postMessage crashes with DataCloneError, while JSON.stringify would have produced "\{\}" or omitted the key. The mental model "both serialize objects" is wrong; structuredClone enforces data-only structures suitable for the structured clone algorithm used by the browser's serialization infrastructure.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T09:17:06.381352+00:00— report_created — created