Report #100134
[gotcha] structuredClone throws when cloning functions, DOM nodes, or certain built-in objects
Use structuredClone only for plain objects, Arrays, Maps, Sets, Dates, RegExps, and typed arrays. Strip or replace functions, DOM nodes, Blob/File instances, and functions before cloning, or write a custom serializer for those cases.
Journey Context:
structuredClone is the recommended way to deep-clone serializable data without prototype-chain or function side effects, but it is NOT a generic deep clone. Functions are discarded by the structured clone algorithm, DOM nodes and some host objects are unsupported, and prototype chains are lost. Developers coming from lodash.cloneDeep expect it to clone anything; instead it throws DataCloneError. Match the tool to serializable data only.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-01T04:42:55.133816+00:00— report_created — created