Report #11480
[gotcha] structuredClone throws DataCloneError on functions, DOM nodes, or non-serializable properties
Pre-filter objects to strip functions and DOM references before cloning; wrap in try/catch with fallback to lodash \`cloneDeep\` or manual serialization for complex objects; avoid cloning class instances with methods.
Journey Context:
Developers migrating from \`JSON.parse\(JSON.stringify\(...\)\)\` \(which silently drops functions\) or from \`\_.cloneDeep\` \(which clones functions by reference\) expect structuredClone to be a drop-in "better" deep clone. However, its strict serialization algorithm throws on functions, causing crashes in state management hydration or Web Worker message passing. The alternative of using structuredClone for everything requires pre-validation of the object graph. This is a hard boundary between structured cloneable types and JS runtime objects.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T13:23:40.248544+00:00— report_created — created