Dexie.js icon indicating copy to clipboard operation
Dexie.js copied to clipboard

Way to solve DexieDataClone Error

Open Gowtham2003 opened this issue 4 years ago • 4 comments

What exactly is https://dexie.org/docs/DexieErrors/Dexie.DataCloneError and How to prevent /fix it

It broke my whole codebase

Gowtham2003 avatar Aug 10 '21 06:08 Gowtham2003

It means you tried to store an object that contained properties of unsupported (not clonable) types. The supported types are defined in the DOM standard structured cloning.

Examples of supported types: string, number, Blob, typed arrays, Map, Set, CryptoKey, arrays, booleans, null etc. Examples of unsupported types: function, symbol, WebSocket, WeakMap, window, document, etc ...

To "fix it", you first need to debug your code and look at the data you are trying to put into IndexedDB. Does it contain the data you intend it to contain? Or do you have an application bug that makes it try to store a function or something else that isn't clonable?

dfahlander avatar Aug 10 '21 07:08 dfahlander

It means you tried to store an object that contained properties of unsupported (not clonable) types. The supported types are defined in the DOM standard structured cloning.

Examples of supported types: string, number, Blob, typed arrays, Map, Set, CryptoKey, arrays, booleans, null etc. Examples of unsupported types: function, symbol, WebSocket, WeakMap, window, document, etc ...

To "fix it", you first need to debug your code and look at the data you are trying to put into IndexedDB. Does it contain the data you intend it to contain? Or do you have an application bug that makes it try to store a function or something else that isn't clonable?

Thanks I'll Check it

Gowtham2003 avatar Aug 10 '21 08:08 Gowtham2003

Is there any library or a good way to check the members of object is clonable or not by structured cloning algorithm ?

Gowtham2003 avatar Oct 04 '21 09:10 Gowtham2003

Is there any library or a good way to check the members of object is clonable or not by structured cloning algorithm ?

Maybe typeson with preset structuredCloningThrowing from typeson-registry. To test against the real DOM you could also start a Worker and do postMessage() to it with your object.

dfahlander avatar Oct 04 '21 11:10 dfahlander