Skip to content

Commit 72d39bd

Browse files
committed
Ensuring promise resolves on abort.
1 parent 2638b24 commit 72d39bd

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/web/src/db/adapters/WorkerWrappedAsyncDatabaseConnection.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ export class WorkerWrappedAsyncDatabaseConnection<Config extends ResolvedWebSQLO
5555
* This lock will be held as long as this connection is open.
5656
* The `shareConnection` method should not be called on multiple tabs concurrently.
5757
*/
58-
await new Promise<void>((lockObtained, reject) =>
58+
await new Promise<void>((resolve, reject) =>
5959
navigator.locks
6060
.request(
6161
`shared-connection-${this.options.identifier}`,
6262
{
6363
signal: this.lockAbortController.signal
6464
},
6565
async () => {
66-
lockObtained();
66+
resolve();
6767

6868
// Free the lock when the connection is already closed.
6969
if (this.lockAbortController.signal.aborted) {
@@ -80,7 +80,9 @@ export class WorkerWrappedAsyncDatabaseConnection<Config extends ResolvedWebSQLO
8080
)
8181
// We aren't concerned with abort errors here
8282
.catch((ex) => {
83-
if (ex.name != 'AbortError') {
83+
if (ex.name == 'AbortError') {
84+
resolve();
85+
} else {
8486
reject(ex);
8587
}
8688
})

0 commit comments

Comments
 (0)