diff --git a/Libraries/LibWeb/IndexedDB/Internal/Algorithms.cpp b/Libraries/LibWeb/IndexedDB/Internal/Algorithms.cpp index aa37c794520..bcc208cac5e 100644 --- a/Libraries/LibWeb/IndexedDB/Internal/Algorithms.cpp +++ b/Libraries/LibWeb/IndexedDB/Internal/Algorithms.cpp @@ -401,21 +401,25 @@ GC::Ref upgrade_a_database(JS::Realm& realm, GC::Refset_state(IDBTransaction::TransactionState::Inactive); + // AD-HOC: If the transaction was aborted by the event, then DONT set the transaction back to inactive. + // https://github.com/w3c/IndexedDB/issues/436#issuecomment-2791113467 + if (transaction->state() != IDBTransaction::TransactionState::Finished) { - // 7. If didThrow is true, run abort a transaction with transaction and a newly created "AbortError" DOMException. - if (did_throw) - abort_a_transaction(*transaction, WebIDL::AbortError::create(realm, "Version change event threw an exception"_string)); + // 6. Set transaction’s state to inactive. + transaction->set_state(IDBTransaction::TransactionState::Inactive); - // AD-HOC: - // https://github.com/w3c/IndexedDB/issues/436 - // The implementation must attempt to commit a transaction when all requests placed against the transaction have completed - // and their returned results handled, - // no new requests have been placed against the transaction, - // and the transaction has not been aborted. - if (transaction->state() == IDBTransaction::TransactionState::Inactive && transaction->request_list().is_empty() && !transaction->aborted()) - commit_a_transaction(realm, transaction); + // 7. If didThrow is true, run abort a transaction with transaction and a newly created "AbortError" DOMException. + if (did_throw) + abort_a_transaction(transaction, WebIDL::AbortError::create(realm, "Version change event threw an exception"_string)); + + // AD-HOC: + // The implementation must attempt to commit a transaction when all requests placed against the transaction have completed + // and their returned results handled, + // no new requests have been placed against the transaction, + // and the transaction has not been aborted. + if (transaction->state() == IDBTransaction::TransactionState::Inactive && transaction->request_list().is_empty() && !transaction->aborted()) + commit_a_transaction(realm, transaction); + } })); // 11. Wait for transaction to finish.