Report #71779
[gotcha] structuredClone throws DataCloneError on functions, DOM nodes, or non-serializable types
Strip functions, DOM nodes, and non-serializable properties before calling structuredClone; use a replacer or manual mapping to convert these to serializable alternatives \(e.g., storing function names as strings\).
Journey Context:
structuredClone is often used as a drop-in replacement for JSON.parse\(JSON.stringify\(\)\) to handle more types \(Map, Set, ArrayBuffer\), but unlike JSON methods, it throws a DataCloneError when encountering functions, DOM nodes, or certain host objects. This crashes applications that previously used JSON serialization which silently stripped functions. The error is particularly surprising because structuredClone preserves referential identity for circular references but cannot handle code.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T03:03:47.250975+00:00— report_created — created