Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found.
Closed this issue · 1 comments
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#L93
fetchUpdates
then calls idb.transact
with the updates store name to retrieve the "updates" store https://github.com/yjs/y-indexeddb/blob/master/src/y-indexeddb.js#L17
idb.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
- Browser: the error has been reported from Chrome 114.0.0, Chrome 115.0.0 and Edge 114.0.1823
- yjs v13.5.50, y-indexeddb v9.011,
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!
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.