Report #97789
[gotcha] structuredClone throws on functions, DOM nodes, and prototype chains
Use structuredClone only for plain transferable data; for class instances implement custom serialization, a toJSON method, or a library. Do not expect methods, DOM nodes, or functions to survive cloning.
Journey Context:
structuredClone is deep and supports more types than JSON, but it throws DataCloneError for functions and DOM nodes and strips methods and prototypes from class instances. Developers often assume it clones anything because it is 'deep'. Knowing the structured clone algorithm's whitelist prevents surprise data loss.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-26T04:42:06.264987+00:00— report_created — created