Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataCloneError saving an object with a function key #5

Closed
arolson101 opened this issue Jan 22, 2018 · 2 comments
Closed

DataCloneError saving an object with a function key #5

arolson101 opened this issue Jan 22, 2018 · 2 comments

Comments

@arolson101
Copy link

arolson101 commented Jan 22, 2018

I'm using dexie-observable under node.js through fake-indexeddb. Through a series of events it ends up calling put on an object with a save prototype method, which fails because lodash's isPlainObject returns false:

    } else if (!isPlainObject(input)) {
        // This is way too restrictive. Should be able to clone any object that isn't
        // a platform object with an internal slot other than [[Prototype]] or [[Extensible]].
        // But need to reject all platform objects, except those whitelisted for cloning
        // (ie, those with a [[Clone]] internal method), and this errs on the side of caution
        // for now.

        // Supposed to also handle FileList, ImageData, ImageBitmap, but fuck it
        throw new DataCloneError();
    } else {

According to the structured clone algorithm this should be ok- the object will be duplicated but "The prototype chain does not get walked and duplicated".

For comparison, Chrome's IndexedDB implementation allows the object to be saved.

reference: dexie/Dexie.js#647

@dumbmatter
Copy link
Owner

Thanks for the bug report and the link to the Dexie discussion. I will have to try typeson some time and see how it performs.

@dumbmatter
Copy link
Owner

This is fixed in realistic-structured-clone v2.0.0 and fake-indexeddb v2.0.4. Thanks again for the bug report!

Your bug report also led to a couple unrelated bug fixes in Typeson because I noticed some minor issues there when I started playing around with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants