Report #101530
[gotcha] structuredClone silently drops functions, prototype chains, getters/setters, private fields, and non-serializable objects
Treat structuredClone as a data-only snapshot. Convert functions to strategy identifiers, replace class instances with plain objects before cloning, and rehydrate on the other side. For class preservation, use a custom replacer/reviver or a serialization library.
Journey Context:
structuredClone is convenient for postMessage and IndexedDB, but it clones the own enumerable data properties into plain Objects/Arrays/Maps/Sets. It does not preserve methods, prototypes, accessors, or property descriptors. Code that sends class instances across a Worker gets back dumb objects with no methods. The fix is to separate data from behavior: serialize to a schema and reconstruct the typed object at the destination.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-07T05:00:42.253022+00:00— report_created — created