Fix deletions
Some checks failed
Check / build (pull_request) Has been cancelled
E2E tests / build (pull_request) Has been cancelled
Publish CLI / publish-docker (pull_request) Has been cancelled
Publish server Docker image / publish-docker (pull_request) Has been cancelled

This commit is contained in:
Andras Schmelczer 2026-05-14 20:58:14 +01:00
commit 36695e9361

View file

@ -876,6 +876,23 @@ export class Syncer {
return this.processRemoteUpdate(trackedRecord, remoteVersion);
}
// Tombstoned: we removed this doc in this session via
// `removeDocumentById` (either WS delete receipt or PUT response
// with `isDeleted=true`). A late RemoteChange for the same doc
// can still reach us — buffered in the network-chaos jitter
// pipeline, or re-enqueued after the delete's purge — and
// without this gate `processRemoteCreateForNewDocument` would
// happily fetch pre-delete bytes and resurrect the doc, blocking
// any other doc whose `remoteRelativePath` happens to be the
// same slot.
if (this.queue.hasBeenDeleted(remoteVersion.documentId)) {
this.queue.lastSeenUpdateId = remoteVersion.vaultUpdateId;
this.logger.debug(
`Discarding stale remote update for tombstoned ${remoteVersion.documentId} at ${remoteVersion.relativePath}`
);
return;
}
return this.processRemoteCreateForNewDocument(remoteVersion);
}