Skip to content

Commit fafd562

Browse files
authored
Navigator locks are now aquired with a random/unique key. (#546)
1 parent 4368351 commit fafd562

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

.changeset/khaki-pears-add.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@powersync/web': minor
3+
---
4+
5+
Navigator locks are now aquired with a random/unique key.
6+
7+
This resolves an issue related to sequential `connect()` calls breaking all syncing and never reaching a `connected` state.
8+
Two typical scenarios that can cause this is switching client parameters and React's `StrictMode` which does multiple calls of hooks like `useEffect`.

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export class WorkerWrappedAsyncDatabaseConnection<Config extends ResolvedWebSQLO
5858
await new Promise<void>((resolve, reject) =>
5959
navigator.locks
6060
.request(
61-
`shared-connection-${this.options.identifier}`,
61+
`shared-connection-${this.options.identifier}-${Date.now()}-${Math.round(Math.random() * 10000)}`,
6262
{
6363
signal: this.lockAbortController.signal
6464
},

0 commit comments

Comments
 (0)