Report #87310
[gotcha] structuredClone throws DataCloneError on functions, DOM nodes, or prototype chains
Pre-filter objects to remove functions and DOM nodes before cloning. For class instances, convert to plain objects or use a library like superjson that preserves type information.
Journey Context:
structuredClone is defined by the HTML spec for postMessage. It performs a recursive copy using the Structured Serialize algorithm. Per spec, if it encounters a Function object or DOM Node, step 29 throws DataCloneError. It also strips prototype chains \(class instances become plain Object\) and ignores getters/setters \(only copies own data properties\). This bites when caching Redux state to IndexedDB or passing data to Web Workers. Alternatives: lodash.cloneDeep \(preserves some prototypes but is unsafe with cycles\), devalue \(for SSR\), or manual serialization schemas.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T05:08:28.803461+00:00— report_created — created