2012-05-04 35 views
5

我們正在構建一個應用程序,它廣泛使用Firefox上的IndexedDB來存儲脫機數據。錯誤「操作失敗,因爲找不到請求的數據庫對象......」使用indexedDB時

這種運作良好,大部分的時間,但偶爾會失敗,就像錯誤如下:

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)" 

似乎在代碼的不同位置失敗;這裏是元兇之一:

_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 

這讓我爲難的是,很少發生失敗,在自動化測試平時的工作(我們看到的每數百處決這些失敗的一個)的事情。

值得一提的是,我們也存儲了大量的數據,數據量爲數百兆字節。 原來自動化測試只存儲幾兆字節,所以它不是一個大小問題。

有沒有其他人經歷過(或者更好的是,經驗豐富和修復!)這個問題?

回答

0

檢查當發生這種情況時是否打開多個選項卡。如果其中一個在setVersion(舊API)或onupgradedneeded(新API)中,可能會導致另一個問題。

要進行調試,請確保您在打開數據庫時查找onblocked(與onerror)事件。

+0

感謝 - 但它發生在督促只有一個單一的標籤在單個瀏覽器實例中。 –

相關問題