diff --git a/.changeset/khaki-pears-add.md b/.changeset/khaki-pears-add.md new file mode 100644 index 000000000..a4b904434 --- /dev/null +++ b/.changeset/khaki-pears-add.md @@ -0,0 +1,8 @@ +--- +'@powersync/web': minor +--- + +Navigator locks are now aquired with a random/unique key. + +This resolves an issue related to sequential `connect()` calls breaking all syncing and never reaching a `connected` state. +Two typical scenarios that can cause this is switching client parameters and React's `StrictMode` which does multiple calls of hooks like `useEffect`. diff --git a/packages/web/src/db/adapters/WorkerWrappedAsyncDatabaseConnection.ts b/packages/web/src/db/adapters/WorkerWrappedAsyncDatabaseConnection.ts index 5004ad9ea..57808e3ce 100644 --- a/packages/web/src/db/adapters/WorkerWrappedAsyncDatabaseConnection.ts +++ b/packages/web/src/db/adapters/WorkerWrappedAsyncDatabaseConnection.ts @@ -58,7 +58,7 @@ export class WorkerWrappedAsyncDatabaseConnection((resolve, reject) => navigator.locks .request( - `shared-connection-${this.options.identifier}`, + `shared-connection-${this.options.identifier}-${Date.now()}-${Math.round(Math.random() * 10000)}`, { signal: this.lockAbortController.signal },