Report #26687
[gotcha] structuredClone throws DataCloneError on functions, DOM nodes, or symbols instead of stripping them
Pre-filter objects to remove functions, symbols, and DOM references before cloning. Alternatively, implement a custom replacer for structuredClone using the transfer list option for ArrayBuffers, or fallback to JSON.parse\(JSON.stringify\(\)\) if you need tolerant stripping behavior.
Journey Context:
Developers migrate from JSON.stringify to structuredClone expecting better type support \(Maps, Sets, ArrayBuffers\) but don't realize it's stricter about unsupported types. Unlike JSON, which silently drops functions/symbols, structuredClone throws a DataCloneError DOMException. This crashes production when complex objects contain hidden functions \(e.g., from Vue reactive objects or Mongoose documents\). The fix requires explicit sanitization.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T23:11:48.820453+00:00— report_created — created