Repository navigation
Closed
Labels
Description
Initial Checklist
- I understand this is a bug report and questions should be posted in the Community Discussions
- I searched issues and couldn’t find anything (or linked relevant results below)
Bug Description
A late joiner to a yjs collaboration session that holds a newer etag than nativeEtag can't always claim recovery. The issue occurs in this (unlikely) scenario:
- A opens file,
etag: E0 - external write →
E1 - B joins
@E1→ flagsisStale,nativeEtag: E1,claim: B - external write →
E2 - C joins
@E2→isStaleis already up for B,E2 ≠ E1→ early return - B resumes → publishes
E1body, stampsE1(though disk isE2)
So basically user C joining with a new etag while user B is still in recovery, which they just claimed. This is an edge-case and somewhat hard to reproduce. I was able to with these steps that my agent gave me:
Reproduction Steps
- Tab A opens the file. Room baseline
_oc_meta.etag: E0. - External write →
E1, outside the room - Tab B: open devtools, find
useYjsSession.tsin sources, set a breakpoint on line 594 (isRewritingDoc=true). Then navigate to the file in that tab. B fetchesE1,flagStalepublishesisStale: true+nativeEtag: E1+recoveryClientId: B, and B stops on the breakpoint - past both guards, before it rewrites anything. - External write →
E2.nativeEtagis now anetagnobody will ever fetch again. - Tab C: set a breakpoint first:
if (!unref(effectiveReadOnly) && canSupplyRecoveryContent(meta)). - Step over:
canSupplyRecoveryContent(meta) = false→ early return, no claim. The editor shows the room'sE0body while disk holdsE2. - 2 different scenarios, both are an issue:
- Resume B → it publishes the
E1body and stampsetag: E1. Everyone now seesE1, the room believes disk isE1, and the next save gets a412thatwasWrittenByRoom(E2)rejects → conflict popup. - Close B's tab while paused (= simulates B closing the editor before their stale recovery ran through) → the flag stays up with a claim nobody will honor. A keeps editing the
E0body, every save ends in the conflict popup, and no later joiner can clear it. The room is permanently damaged.
Expected Outcome
The late joiner claims recovery and successfully recovers the room to the newest etag, despite their new etag not matching nativeEtag.
Actual Outcome
The later joiner can't claim recovery, hence the room is stale without anybody noticing.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
[-]A yjs session joiner with a newer etag than `nativeEtag` can't always claim recovery[/-][+]A yjs session joiner with a new etag can't always claim recovery[/+]