Skip to content

Commit de7804f

Browse files
restore collectActiveSubscriptions
1 parent b0dd596 commit de7804f

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,10 +368,18 @@ export class SharedSyncImplementation extends BaseObserver<SharedSyncImplementat
368368
}
369369

370370
// Re-index subscriptions, the subscriptions of the removed port would no longer be considered.
371-
this.collectActiveSubscriptions();
372371
if (shouldReconnect) {
373-
// The internals of this needs a port mutex lock. It should be safe to start this operation here, but we cannot and don't need to await it.
374-
this.connectionManager.connect(CONNECTOR_PLACEHOLDER, this.lastConnectOptions ?? {});
372+
/**
373+
* The internals of this needs a port mutex lock.
374+
* It should be safe to start this operation here, but we cannot and don't need to await it.
375+
* Since we disconnected, we need to collectActiveSubscriptions after reconnecting.
376+
*/
377+
this.connectionManager
378+
.connect(CONNECTOR_PLACEHOLDER, this.lastConnectOptions ?? {})
379+
.then(() => this.collectActiveSubscriptions());
380+
} else {
381+
// The port removed was not the database in use. We didn't need to reconnect explicitly, but we need to update the subscriptions.
382+
this.collectActiveSubscriptions();
375383
}
376384

377385
return () => trackedPort.clientProvider[Comlink.releaseProxy]();

0 commit comments

Comments
 (0)