Report #59834
[gotcha] structuredClone throws DataCloneError for functions and DOM nodes instead of stripping them
Pre-filter objects to recursively strip functions, DOM nodes, and host objects before calling structuredClone, or implement a custom replacer; do not treat structuredClone as a drop-in replacement for JSON.parse\(JSON.stringify\(\)\)
Journey Context:
Migrating from \`JSON.parse\(JSON.stringify\(\)\)\` to \`structuredClone\` preserves types like Map, Set, and Date, but \`structuredClone\` is stricter: it throws a \`DataCloneError\` for functions, DOM nodes, and non-serializable host objects, whereas JSON methods silently omit functions. This causes runtime crashes in browser apps when cloning component state that holds method references or DOM refs. Defensive filtering is required before cloning.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T06:55:16.521435+00:00— report_created — created