I'm using IndexedDB to store some data. It appears to work, but if I refresh the page, I see: An IndexedDB transaction that was not yet complete has been aborted due to page navigation.
in the browser console on Firefox (36.0.4). I'm using this (local) file to test:
<html>
<head><meta charset="UTF-8"></head>
<body>
<script>
var request = window.indexedDB.open("test_db", 2);
request.onupgradeneeded = function (event) {
request.result.createObjectStore("test_store");
};
request.onsuccess = function (event) {
var db = request.result;
var transaction = db.transaction(["test_store"], "readwrite");
var put = transaction.objectStore("test_store").put("key", "value");
transaction.oncomplete = function (event) {
console.log("Transaction complete");
};
};
</script>
</body>
</html>
If I perform multiple transactions, I get multiple errors. If I have an onclick
handler that performs a transaction and I click it several times, refreshing prints one error for each transaction I made in the past.
All this makes me think my transactions aren't being cleaned up. What do I need to do to finish a transaction?
My oncomplete
handler is being called. Refreshing a few times, the browser console looks like this:
"Transaction complete" test.html:16:1
An IndexedDB transaction that was not yet complete has been aborted due to page navigation. test.html:13:0
"Transaction complete" test.html:16:1
An IndexedDB transaction that was not yet complete has been aborted due to page navigation. test.html:13:0
"Transaction complete" test.html:16:1
Test page (Ctrl-Shift-J to open console, then Ctrl-R to refresh shows the error):