关于 html:Error \\”Operation failed because the required database object could not be found…\\” 使用 indexedDB 时

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

我们正在构建一个应用程序,该应用程序在 Firefox 上广泛使用 IndexedDB 来存储离线数据。

这在大多数情况下运行良好,但偶尔会失败并出现如下错误:

1
2
3
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)"

好像在代码的各个地方都失败了;这是罪魁祸首之一:

1
2
3
4
5
6
7
8
9
10
11
12
_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

令我感到困惑的是,在通常有效的自动化测试期间,这些故障很少发生(我们每执行数百次就会看到这些故障之一)。

值得一提的是,我们也存储了大量数据,大约有数百兆字节。 原来自动化测试只存储了几兆字节,所以这不是大小问题.

有没有其他人经历过(或者更好,经历过并修复过!)这个问题?


这似乎是一个 Firefox 错误。我提出了错误 751802 - 间歇性 IndexedDB 写入失败,我和我的同事正忙于与 Firefox 人员合作以帮助重现它。

暂时没有解决方法或修复方法。


添加到@Duncan 的答案:

在那个线程上是一个在数据库创建/打开中抛出一个捕获的想法

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


发生这种情况时,请检查您是否打开了多个选项卡。如果其中一个在 setVersion(旧 API)或 onupgradedneeded(新 API)中,则可能会导致另一个问题。

要进行调试,请确保在打开数据库时查找 onblocked(与 onerror)事件。