We're building an application that makes extensive use of IndexedDB on Firefox to store offline data.
This works well most of the time but occasionally fails with errors like the following:
Exception... "The operation failed because the requested database object could
not be found. For example, an object store did not exist but was being opened."
code: "3" nsresult: "0x80660003 (NS_ERROR_DOM_INDEXEDDB_NOT_FOUND_ERR)"
It seems to fail in various places in the code; here is one of the culprits:
_writePage: (storeName, startIndex, endIndex, binder) ->
writeTransaction = @connection.transaction([storeName], @idbTransaction.READ_WRITE)
store = writeTransaction.objectStore(storeName)
for index in [startIndex...endIndex] when (item = binder.list[index])?
writeRequest = store.put(item)
writeRequest.onerror = binder.failCallback()
writeRequest.onsuccess = binder.successCallback()
if endIndex >= binder.list.length
binder.finishedRegisteringCallbacks()
return
setTimeout((=> @_writePage(storeName, endIndex, endIndex + @WRITE_EACH_PAGE_SIZE, binder)), @WRITE_EACH_PAGE_DELAY)
null
The thing that puzzles me is that the failures occur infrequently, during automated tests that usually work (we're seeing one of these failures per hundreds of executions).
It's worth mentioning that we're storing a lot of data too, in the order of hundreds of megabytes. Turns out the automated tests only store a few megabytes, so it's not a matter of size.
Has anyone else experienced (or better yet, experienced and fixed!) this problem?
Structuring the database. Now to structure the database. IndexedDB uses object stores rather than tables, and a single database can contain any number of object stores.
To get a single specific object, the get(key) method is used, to which the key of the object to be obtained is passed as a parameter. The requested data is returned as a result of the request. 💡 This method returns undefined as a result if the stored object has an undefined value or the object doens't exist.
IndexedDB is a low-level API for client-side storage of significant amounts of structured data, including files/blobs. This API uses indexes to enable high-performance searches of this data. While Web Storage is useful for storing smaller amounts of data, it is less useful for storing larger amounts of structured data.
This seems to be a Firefox bug. I've raised Bug 751802 - Intermittent IndexedDB write failures and my colleagues and I are busy working with the Firefox folks to help reproduce it.
For the time being there's no workaround or fix.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With