dumbmatter / fakeIndexedDB

A pure JS in-memory implementation of the IndexedDB API
Apache License 2.0
585 stars 70 forks source link

DataCloneErrors with v1.0.10 #17

Closed dpogue closed 7 years ago

dpogue commented 7 years ago

Started running into failing tests when I upgraded fakeIDB this morning:

beforeEach(function(done) {
  let dbReq = fakeIndexedDB.open('storage', 2);

  dbReq.onerror = (e) => {
    console.error(e);
    done(dbReq.error);
  };

  dbReq.onupgradeneeded = (e) => {
    dbReq.result.createObjectStore('test', { keyPath: 'key' });
  };

  dbReq.onsuccess = (e) => {
    let txn = dbReq.result.transaction(['test'], 'readwrite');
    let os = txn.objectStore('test');

    let p = os.put({key: 'name', value: 'test'});  // <-- FAILING
    p.onsuccess = () => {
      dbReq.result.close();
      done();
    };
  };
});

The put call is now throwing DataCloneError: The data being stored could not be cloned by the internal structured cloning algorithm.

dumbmatter commented 7 years ago

Sorry about that. What version of Node? I might inadvertently be using a feature not in old versions.

On Feb 6, 2017 2:34 PM, "Darryl Pogue" notifications@github.com wrote:

Started running into failing tests when I upgraded fakeIDB this morning:

beforeEach(function(done) { let dbReq = fakeIndexedDB.open('storage', 2);

dbReq.onerror = (e) => { console.error(e); done(dbReq.error); };

dbReq.onupgradeneeded = (e) => { dbReq.result.createObjectStore('test', { keyPath: 'key' }); };

dbReq.onsuccess = (e) => { let txn = dbReq.result.transaction(['test'], 'readwrite'); let os = txn.objectStore('test');

let p = os.put({key: 'name', value: 'test'});  // <-- FAILING
p.onsuccess = () => {
  dbReq.result.close();
  done();
};

}; });

The put call is now throwing DataCloneError: The data being stored could not be cloned by the internal structured cloning algorithm.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/dumbmatter/fakeIndexedDB/issues/17, or mute the thread https://github.com/notifications/unsubscribe-auth/AAyk2MSWUt3kJuNNLsIolH0aX1gfZC7uks5rZ3XIgaJpZM4L4nr_ .

dpogue commented 7 years ago

It's node 7, but I'm running in PhantomJS (which is lacking several things, which is partly why we're using fakeIndexedDB 😢). I do have a ES6 Map/Set polyfill.

dumbmatter commented 7 years ago

It does now require a Map/Set polyfill in PhantomJS, when previously it did not. But there was also another incompatibility related to PhantomJS having a really old ArrayBuffer implementation that I didn't realize. That's fixed now in v1.0.11. Thanks for the bug report!

dpogue commented 7 years ago

Thanks!! v1.0.11 is working :)