From 4a66ec74000f59b4057dc1f03e6184b5574807b3 Mon Sep 17 00:00:00 2001 From: EYHN Date: Fri, 21 Feb 2025 19:10:16 +0800 Subject: [PATCH] fix(nbstore): fix doc clock check logic (#10355) --- packages/common/nbstore/src/sync/doc/peer.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/common/nbstore/src/sync/doc/peer.ts b/packages/common/nbstore/src/sync/doc/peer.ts index 27048919c..9cfdcb7e1 100644 --- a/packages/common/nbstore/src/sync/doc/peer.ts +++ b/packages/common/nbstore/src/sync/doc/peer.ts @@ -247,7 +247,7 @@ export class DocSyncPeer { !this.remote.isReadonly && clock && (pushedClock === null || - pushedClock.getTime() !== clock.timestamp.getTime()) + pushedClock.getTime() < clock.timestamp.getTime()) ) { await this.jobs.pullAndPush(docId, signal); } else { @@ -255,9 +255,10 @@ export class DocSyncPeer { const pulled = (await this.syncMetadata.getPeerPulledRemoteClock(this.peerId, docId)) ?.timestamp ?? null; + const remoteClock = this.status.remoteClocks.get(docId); if ( - pulled === null || - pulled.getTime() !== this.status.remoteClocks.get(docId)?.getTime() + remoteClock && + (pulled === null || pulled.getTime() < remoteClock.getTime()) ) { await this.jobs.pull(docId, signal); }