fix(repo): send snapshot for shallow-compacted docs - #18
Open
jacob-petterle wants to merge 1 commit into
Open
Conversation
When a document has been shallow-compacted (oplog history truncated), the sync protocol incorrectly tries to compute a delta update for peers with divergent version vectors. The delta export fails silently because the peer's ops don't exist in the truncated oplog, causing the protocol to falsely report "synced" with zero data transferred. Detect shallow docs via shallowSinceVV() and force snapshot mode, which always contains the full current state and imports correctly into any peer regardless of their version vector. Non-shallow docs are completely unaffected — the isShallow check evaluates to false, preserving the existing isEmpty-based logic. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
shallowSinceVV()and force snapshot modeRoot cause: After daemon compacts conversation docs to shallow snapshots, the browser initializes 20 schema ops with its own peer ID. When the daemon tries
export({ mode: 'update', from: browserVersion }), the shallow doc can't compute the delta because the browser's peer ops don't exist in the truncated oplog. The protocol marks sync as "synced" with 0 data.Fix: 5-line change in
#buildSyncResponseMessage— detect shallow docs and send full snapshot instead of delta.Risk
Essentially zero.
isShallow = false→useSnapshot = isEmpty→ identical to beforeshallowSinceVV()is a stable Loro APITest plan
handle-sync-request.test.tstests pass (9/9)🤖 Generated with Claude Code