Skip to content

Commit 0f1cb7c

Browse files
Code cleanup. make minor bump.
1 parent cf14827 commit 0f1cb7c

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

.changeset/rare-windows-argue.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
'@powersync/web': patch
2+
'@powersync/web': minor
33
---
44

55
- Fixed some edge cases where multiple tabs with OPFS can cause sync deadlocks.

packages/web/src/worker/db/WASQLiteDB.worker.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const OPEN_DB_LOCK = 'open-wasqlite-db';
2020
let nextClientId = 1;
2121

2222
const openDBShared = async (options: WorkerDBOpenerOptions): Promise<AsyncDatabaseConnection> => {
23+
// Prevent multiple simultaneous opens from causing race conditions
2324
return getNavigatorLocks().request(OPEN_DB_LOCK, async () => {
2425
const clientId = nextClientId++;
2526
const { dbFilename, logLevel } = options;

packages/web/src/worker/sync/SharedSyncImplementation.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ export class SharedSyncImplementation extends BaseObserver<SharedSyncImplementat
190190
*/
191191
protected async getRandomWrappedPort(): Promise<WrappedSyncPort | undefined> {
192192
return await this.portMutex.runExclusive(() => {
193-
return this.ports[Math.floor(Math.random() * this.ports.length)];
193+
const nonClosingPorts = this.ports.filter((p) => !p.isClosing);
194+
return nonClosingPorts[Math.floor(Math.random() * nonClosingPorts.length)];
194195
});
195196
}
196197

0 commit comments

Comments
 (0)