Skip to content

fix(yjs): let the server decide who seeds an empty room - #3331

Open
JammingBen wants to merge 2 commits into
mainfrom
fix/yjs-hydration-race-errors
Open

fix(yjs): let the server decide who seeds an empty room#3331
JammingBen wants to merge 2 commits into
mainfrom
fix/yjs-hydration-race-errors

Conversation

@JammingBen

@JammingBen JammingBen commented Sep 8, 2026

Copy link
Copy Markdown
Member

Two clients opening the same file at once could both seed the Y.Doc, and the room then held the body twice. The awareness election that guarded this only waited a guessed 150ms.

Instead of solving this on the client side, the Yjs server now grants seeding to exactly one connection per room. It is the only party that sees every connection at once.

The grant is permission, not an instruction: the client still checks its own document first, so a grant for a room that already has content costs nothing. It passes to another writer when the holder leaves, and dies with the room.

fixes #3141

@JammingBen JammingBen self-assigned this Sep 8, 2026
Two clients opening the same file at once could both seed the Y.Doc, and
the room then held the body twice. The awareness election that guarded
this only waited a guessed 150ms, and a client has no signal that its
announce is visible to everyone.

The Yjs server now grants seeding to exactly one connection per room. It
is the only party that sees every connection at once, so no wait has to
be guessed.

The grant is permission, not an instruction: the client still checks its
own document first, so a grant for a room that already has content costs
nothing. It passes to another writer when the holder leaves, and dies
with the room.
@JammingBen
JammingBen force-pushed the fix/yjs-hydration-race-errors branch from f16fe78 to fb38a4a Compare September 8, 2026 09:40
@JammingBen
JammingBen marked this pull request as ready for review September 8, 2026 10:24
@JammingBen
JammingBen requested a review from kulmann September 8, 2026 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Y.Doc hydration can race

1 participant