Re: [w3c/IndexedDB] Should IDBDatabase::close() be in parallel? (Issue #474)

asutherland left a comment (w3c/IndexedDB#474)

It does seem like most of the algorithms currently expect to be run "in parallel" and https://w3c.github.io/IndexedDB/#close-a-database-connection explicitly is mixing things that must be done synchronously on the agent thread with things that must happen in parallel (but sequentially for the db/all its connections) so it could make sense to:

Change close()'s algorithm to be:

1. If connection's close pending flag is set, return.
2. Set connection’s [close pending flag](https://w3c.github.io/IndexedDB/#connection-close-pending-flag) to true.
3. Run these steps in parallel.
   1. Run [close a database connection](https://w3c.github.io/IndexedDB/#close-a-database-connection) with this [connection](https://w3c.github.io/IndexedDB/#connection).

We'd then update https://w3c.github.io/IndexedDB/#close-a-database-connection to also handle the need to queue a task since you can't dispatch an event from the "in parallel" conceptual thread, so that text would become:

1. If the forced flag is true, then for each transaction [created](https://w3c.github.io/IndexedDB/#transaction-created) using connection run [abort a transaction](https://w3c.github.io/IndexedDB/#abort-a-transaction) with transaction and newly [created](https://webidl.spec.whatwg.org/#dfn-create-exception) "[AbortError](https://webidl.spec.whatwg.org/#aborterror)" [DOMException](https://webidl.spec.whatwg.org/#idl-DOMException).
2. Wait for all transactions [created](https://w3c.github.io/IndexedDB/#transaction-created) using connection to complete. Once they are complete, connection is [closed](https://w3c.github.io/IndexedDB/#connection-closed).
3. If the forced flag is true, then [queue a database task](https://w3c.github.io/IndexedDB/#queue-a-database-task) to [fire an event](https://dom.spec.whatwg.org/#concept-event-fire) named [close](https://w3c.github.io/IndexedDB/#eventdef-idbdatabase-close) at connection.

And I think that's compatible with the existing https://w3c.github.io/IndexedDB/#close-a-database-connection use of https://w3c.github.io/IndexedDB/#close-a-database-connection.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/IndexedDB/issues/474#issuecomment-3321633532
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/IndexedDB/issues/474/3321633532@github.com>

Received on Monday, 22 September 2025 22:03:53 UTC