Skip to content

Autocommit IDBTransactions #39178

@arihant2math

Description

@arihant2math

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:

https://www.w3.org/TR/IndexedDB-2/#transaction-commit

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-content/indexeddbIndexedDB implementation issues.E-more-complexVariable effort required; may require a mentor. Recommended solution is clearly described in the issI-wrongAn incorrect behaviour is observed.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions