-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Autocommit IDBTransactions #39178
Description
Consider the following test:
/* IndexedDB: Exception Order of IDBObjectStore.createIndex() */
indexeddb_test(
function (t, db, txn) {
let store = db.createObjectStore("s");
},
function (t, db) {
let txn = db.transaction("s", "readonly");
console.log("created readonly txn");
let store = txn.objectStore("s");
console.log("Starting readonly txn");
txn.oncomplete = function () {
console.log("txn complete");
assert_throws_dom("InvalidStateError", function () {
store.createIndex("index", "foo");
});
t.done();
};
},
"InvalidStateError(Incorrect mode) vs. TransactionInactiveError. Mode check should precede state check of the transaction."
);Currently, this causes a timeout. Why? oncomplete is never fired. However https://www.w3.org/TR/IndexedDB-2/#dom-idbtransaction-objectstore never references firing the "complete" event. Initially I though this was due to an unfired "complete" event, but actually this occurs because we don't autocommit transactions:
When a transaction has been started and it can no longer become active, the implementation must attempt to commit it, as long as the transaction has not been aborted. This usually happens after all requests placed against the transaction have been executed and their returned results handled, and no new requests have been placed against the transaction. When a transaction is committed, the implementation must atomically write any changes to the database made by requests placed against the transaction. That is, either all of the changes must be written, or if an error occurs, such as a disk write error, the implementation must not write any of the changes to the database.
This also shows that we aren't handling requests atomically, which is a 2nd bug.