Report #87107
[gotcha] structuredClone throws on functions, DOM nodes, and many host objects
Use structuredClone only for plain data trees of serializable types; strip functions, DOM references, and prototype methods before cloning, or implement a custom serializer for those cases.
Journey Context:
structuredClone is the modern way to deep-clone objects, but the structured clone algorithm is deliberately limited to data types it can serialize \(the same set postMessage uses\). Functions, DOM nodes, most host objects, and certain internal slots will throw a DataCloneError. People often try to clone a class instance and lose its methods, or clone an object holding an AbortController and crash. The alternatives are \`JSON.parse\(JSON.stringify\(x\)\)\` \(loses more\) or a manual deep clone. The right call is to keep data DTOs separate from behavior/objects so structuredClone is safe by design.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T04:47:55.227640+00:00— report_created — created