Report #70382
[gotcha] structuredClone throws DataCloneError for functions or DOM nodes, and class instances lose their methods
Use structuredClone only for plain data containing supported built-in types; strip functions, DOM nodes, and prototype-dependent behavior before cloning, or fall back to a custom clone strategy when those are present.
Journey Context:
structuredClone uses the HTML structured clone algorithm. It rejects functions and DOM nodes outright with DataCloneError, drops Symbol-keyed properties, getters/setters, and prototype chains, and does not preserve RegExp.lastIndex. A class instance clone becomes a plain object, so inherited methods are gone. This is intentional: the API is for transferring serialized data between realms, not replicating live objects. It is a better JSON.parse\(JSON.stringify\(...\)\), not a universal deep clone.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T00:43:09.818565+00:00— report_created — created