Report #79843
[gotcha] structuredClone throws DataCloneError on functions, DOM nodes, or non-serializable objects
Strip functions/DOM nodes before cloning, or implement a custom replacer that handles non-serializable types; use libraries like lodash.cloneDeep with customizer for complex cases
Journey Context:
structuredClone uses the HTML Structured Serialize algorithm which explicitly forbids functions, Error objects, DOM nodes, and certain other types. Many assume it works like JSON.parse\(JSON.stringify\(\)\) but with more types, but it actually throws immediately on encountering a function. The fix is either to pre-filter the object or accept that structuredClone is for data-only transfer \(postMessage, IndexedDB\) not general deep cloning.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T16:37:30.304136+00:00— report_created — created