Skip to content

A yjs session joiner with a new etag can't always claim recovery #3132

Closed

Description

@JammingBen

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 → flags isStale, nativeEtag: E1, claim: B
  • external write → E2
  • C joins @E2 → isStale is already up for B, E2 ≠ E1 → early return
  • B resumes → publishes E1 body, stamps E1 (though disk is E2)

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

  1. Tab A opens the file. Room baseline _oc_meta.etag: E0.
  2. External write → E1, outside the room
  3. Tab B: open devtools, find useYjsSession.ts in sources, set a breakpoint on line 594 (isRewritingDoc = true). Then navigate to the file in that tab. B fetches E1, flagStale publishes isStale: true + nativeEtag: E1 + recoveryClientId: B, and B stops on the breakpoint - past both guards, before it rewrites anything.
  4. External write → E2. nativeEtag is now an etag nobody will ever fetch again.
  5. Tab C: set a breakpoint first: if (!unref(effectiveReadOnly) && canSupplyRecoveryContent(meta)).
  6. Step over: canSupplyRecoveryContent(meta) = false → early return, no claim. The editor shows the room's E0 body while disk holds E2.
  7. 2 different scenarios, both are an issue:
  • Resume B → it publishes the E1 body and stamps etag: E1. Everyone now sees E1, the room believes disk is E1, and the next save gets a 412 that wasWrittenByRoom(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 E0 body, 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.

Activity

  1. moved this from Qualification to Prio <= 3 in OpenCloud Team Boardon Aug 14, 2026
  2. changed the title [-]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[/+] on Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions