Report #15009
[gotcha] structuredClone throws DataCloneError for functions, DOM nodes, or non-serializable objects
Before calling structuredClone, strip functions, DOM references, and non-serializable types; use a reviver/replacer pattern or use libraries like lodash.cloneDeep for complex objects containing functions
Journey Context:
structuredClone uses the HTML Structured Clone Algorithm, which supports Maps, Sets, ArrayBuffers, but explicitly forbids functions and DOM nodes. Developers assume it's a drop-in replacement for JSON.parse\(JSON.stringify\(\)\) but with better type support, then get runtime DataCloneError. The fix requires defensive filtering. For mixed data with functions, structuredClone is inappropriate; use manual cloning or accept the serialization boundary constraints.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T22:54:27.131951+00:00— report_created — created