mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
LibWeb: Autocommit IDB transactions with no requests during cleanup
If the current JS task has not made any requests, then nothing else will trigger a commit like the spec desires, so we need to do it in the microtask checkpoint. Two WPT tests no longer time out with this change and have been imported.
This commit is contained in:
committed by
Gregory Bertilson
parent
3f2bb43d47
commit
e8c1c2246e
Notes:
github-actions[bot]
2026-03-05 23:42:10 +00:00
Author: https://github.com/Zaggy1024 Commit: https://github.com/LadybirdBrowser/ladybird/commit/e8c1c2246e2 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8264
@@ -339,6 +339,22 @@ void IDBDatabase::block_on_conflicting_transactions(GC::Ref<IDBTransaction> tran
|
||||
|
||||
transaction->request_list().block_execution();
|
||||
wait_for_transactions_to_finish(blocking, GC::create_function(realm().heap(), [transaction] {
|
||||
VERIFY(transaction->state() != IDBTransaction::TransactionState::Active);
|
||||
if (transaction->request_list().is_empty()) {
|
||||
// https://w3c.github.io/IndexedDB/#transaction-commit
|
||||
// The implementation must attempt to commit an inactive 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 we were blocked, that means that the JS task has had its chance to make requests. If the request
|
||||
// list is empty, then the cleanup in the microtask checkpoint already ran, but skipped auto-committing.
|
||||
// We have to do it here instead.
|
||||
|
||||
// FIXME: Update if this becomes explicit:
|
||||
// https://github.com/w3c/IndexedDB/issues/489#issuecomment-3994928473
|
||||
commit_a_transaction(transaction->realm(), transaction);
|
||||
return;
|
||||
}
|
||||
transaction->request_list().unblock_execution();
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user