Report #14181
[gotcha] structuredClone throws DataCloneError on functions and prototype chains
Strip all functions and class instances before calling structuredClone, or use Lodash's cloneDeep with a customizer for methods. For transferring class instances, implement manual serialization \(toJSON/fromJSON\) rather than relying on structuredClone.
Journey Context:
Unlike Lodash's cloneDeep which preserves methods by reference, the HTML Structured Clone Algorithm explicitly forbids Function objects and DOM nodes to ensure isolation between contexts. When cloning Redux state or configuration objects containing class methods, structuredClone throws a DataCloneError. The surprise is that the error happens at clone time, not at the point where the method is later invoked, masking the source of the uncloneable data.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T20:50:15.155380+00:00— report_created — created