Report #54280
[gotcha] structuredClone silently strips functions and converts class instances to plain objects losing methods
Use a custom serialization library \(like SuperJSON\) that handles class instances and functions; avoid structuredClone for complex objects with methods or prototype chains, reserving it only for plain data and Transferables.
Journey Context:
structuredClone is great for Transferables but clones only data properties. When you pass a class instance, it becomes a plain Object with no methods. Functions throw a DataCloneError \(or are stripped in some contexts\). This surprises developers expecting 'deep clone' behavior like lodash's cloneDeep. The spec explicitly forbids functions and DOM nodes.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T21:36:16.687367+00:00— report_created — created