Skip to content

fix(yjs): keep debounced keystrokes when a peer's recovery lands - #3582

Merged
JammingBen merged 1 commit into
mainfrom
refactor/yjs-sync-serialize
Oct 23, 2026
Merged

JammingBen merged 1 commit into
mainfrom
refactor/yjs-sync-serialize

Conversation

@JammingBen

Copy link
Copy Markdown
Member

A peer's stale flag and rewrite could arrive back to back before the async flush settled, so the dirty check ran after the rewrite and a keystroke still inside the debounce was dropped. Making YjsAdapter.serialize sync lets the flush settle before the rewrite applies. Requiring reset removes the unreachable "cannot recover in-place" lock paths.

Technically this is a breaking change: YjsAdapter.serialize must return a string and reset is required. YjsSession.serializeMerged is now synchronous. This also simplifies the implementation quite a bit.

part of #3428

A peer's stale flag and rewrite could arrive back to back before the async
flush settled, so the dirty check ran after the rewrite and a keystroke still
inside the debounce was dropped. Making YjsAdapter.serialize sync lets the
flush settle before the rewrite applies. Requiring reset removes the
unreachable "cannot recover in-place" lock paths.

BREAKING CHANGE: YjsAdapter.serialize must return a string and reset is
required. YjsSession.serializeMerged is now synchronous.
@JammingBen

Copy link
Copy Markdown
Member Author

As stated in the description above:

Technically this is a breaking change: YjsAdapter.serialize must return a string and reset is required. YjsSession.serializeMerged is now synchronous. This also simplifies the implementation quite a bit.

I checked the excalidraw app and opencloud-eu/web-extensions#598, both are compatible with the change. I don't expect any other implementation out there yet, and even if, it would possibly be unaffected as well. I'm inclined to slip this breaking change under the radar because of that... @kulmann what do you think?

@JammingBen
JammingBen requested a review from kulmann October 7, 2026 12:58
@JammingBen JammingBen self-assigned this Oct 7, 2026
@JammingBen
JammingBen merged commit aceb0e7 into main Oct 23, 2026
32 checks passed
@JammingBen
JammingBen deleted the refactor/yjs-sync-serialize branch October 23, 2026 09:43
@openclouders openclouders mentioned this pull request Oct 23, 2026
1 task
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.

2 participants