Closed h4n4h closed 1 year ago
Found the issue. I was calling const request = indexedDB.open("test name")
before instantiating the new IndexeddbPersistence("test name", new Y.Doc())
to check if a db already existed and when it doesn't, this call to open
actually creates one which means when I call the constructor, the version of the DB isn't 0 anymore and so the callback to create the updates
store doesn't run, since that only runs when the DB is on v0.
Hello! I am on version 9.0.11 of y-indexeddb and am getting this error occasionally
NotFoundError: Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found.
in my monitoring.Looking at the stack trace, the issue starts in the constructor of IndexeddbPersistence where
fetchUpdates
is called https://github.com/yjs/y-indexeddb/blob/master/src/y-indexeddb.js#L93fetchUpdates
then callsidb.transact
with the updates store name to retrieve the "updates" store https://github.com/yjs/y-indexeddb/blob/master/src/y-indexeddb.js#L17idb.transact
then throws the error because the updates store cannot be found.It seems there may be an issue where it tries to fetch the updates store before the db is fully initialised. i.e. before this code is run https://github.com/yjs/y-indexeddb/blob/master/src/y-indexeddb.js#L72 which creates the updates store. (Perhaps some kind of race condition?)
Steps to reproduce the behavior: I have been unable to reproduce this, I am just seeing error logs coming through my monitoring from other users.
Expected behavior The updates store should be found
Environment Information
Extra info: Here is how I am using Indexeddb
const indexedDb = new IndexeddbPersistence("test name", new Y.Doc());
indexedDb?.on?.('synced', () => { // send performance mark for synced db });
I am hoping you can help!