Duncan Bayne
Duncan Bayne

Reputation: 3949

Error "Operation failed because the requested database object could not be found..." when using indexedDB

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?

Upvotes: 4

Views: 5764

Answers (3)

Tamb
Tamb

Reputation: 748

Adding to @Duncan's answer:

On that thread is an idea to throw a catch in db creation/open

https://bugzilla.mozilla.org/show_bug.cgi?id=751802#ch-8

Upvotes: 0

Duncan Bayne
Duncan Bayne

Reputation: 3949

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.

Upvotes: 7

buley
buley

Reputation: 29208

Check to see if you have multiple tabs open when this happens. If one of those is in a setVersion (old API) or onupgradedneeded (new API) it's probably going to cause problems in the other.

To debug, be sure you're looking for onblocked (vs. onerror) events when opening the DB.

Upvotes: 0

Related Questions