Report #99663
[gotcha] structuredClone silently drops functions, DOM nodes, prototype chains, getters/setters, and non-serializable properties
Use structuredClone only for plain, acyclic data made of serializable types. For class instances, functions, or DOM nodes, write explicit copy logic or use a purpose-built library.
Journey Context:
structuredClone is convenient because it preserves Maps, Sets, ArrayBuffers, and Dates, but it is not a generic deep clone. Functions are discarded, class instances become plain objects losing methods, DOM nodes throw DataCloneError, and property descriptors like getters/setters are flattened to values. People often swap JSON.parse\(JSON.stringify\(x\)\) for structuredClone thinking it is a safer deep clone, then discover missing methods in production. Decide per object: plain data -> structuredClone; behavior-bearing objects -> factory/clone method.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-30T04:50:56.903226+00:00— report_created — created