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

5

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?

html
firefox
indexeddb
asked on Stack Overflow May 4, 2012 by Duncan Bayne • edited May 25, 2014 by Josh

3 Answers

5

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.

answered on Stack Overflow May 22, 2012 by Duncan Bayne
0

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.

answered on Stack Overflow May 4, 2012 by buley
0

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

answered on Stack Overflow Jul 28, 2017 by Tamb

User contributions licensed under CC BY-SA 3.0