1. Let queue be the for origin and name.

    2. Add request to queue.

    3. Wait until all previous requests in queue have been processed.

    4. Let db be the database name in origin, or null otherwise.

    1. If version is undefined, let version be 1 if db is null, or db’s version otherwise.

    2. Let connection be a new to db.

    3. Set connection’s version to version.

    4. If db’s is less than version, then:

      1. Let openConnections be the set of all connections, except connection, associated with db.

      2. If any of the in openConnections are still not closed, queue a task to named [blocked](#request-blocked) at request with db’s version and version.

      3. Wait until all in openConnections are closed.

      4. Run the steps to using connection, version and request.

      5. If connection was closed, return a newly ““ [DOMException](https://www.w3.org/TR/WebIDL-1/#idl-DOMException) and abort these steps.

    5. Return connection.