Skip to content

Commit d1c5109

Browse files
committed
Bugfix: every other change not propagated
Bug was introduced recently (in dexie-cloud-addon@4.4.5). A stale syncState was used when sending "ready" event to server, resulting in server propagaing false baseRev back --> client ignoring every other message from server over websocket.
1 parent ffeb6a8 commit d1c5109

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

addons/dexie-cloud/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dexie-cloud-addon",
3-
"version": "4.4.10",
3+
"version": "4.4.11",
44
"description": "Dexie addon that syncs with to Dexie Cloud",
55
"type": "module",
66
"module": "dist/modern/dexie-cloud-addon.js",

addons/dexie-cloud/src/sync/connectWebSocket.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,12 @@ export function connectWebSocket(db: DexieCloudDB) {
6161

6262
const readyForChangesMessage = db.messageConsumer.readyToServe.pipe(
6363
filter((isReady) => isReady), // When consumer is ready for new messages, produce such a message to inform server about it
64-
switchMap(() =>
65-
db.cloud.persistedSyncState.pipe(
66-
filter((syncState) => !!(syncState && syncState.serverRevision)),
67-
take(1)
68-
)
69-
), // Wait reactively for syncState with serverRevision (avoids race with logout/re-sync)
70-
switchMap<PersistedSyncState, Promise<ReadyForChangesMessage>>(
64+
switchMap(() => db.getPersistedSyncState()),
65+
filter(
66+
(syncState): syncState is PersistedSyncState =>
67+
!!(syncState && syncState.serverRevision)
68+
),
69+
switchMap(
7170
async (syncState) =>
7271
({
7372
// Produce the message to trigger server to send us new messages to consume:

0 commit comments

Comments
 (0)