Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix how remote ops are applied during open phase #46

Merged
merged 3 commits into from
Mar 27, 2024

Conversation

nickbrowne
Copy link
Contributor

This fixes a rare but very annoying bug where you have 2 clients actively connected to the same document, one disconnects, but continues to make changes (creating a pending op), and the other continues to make changes, when the disconnected client reconnects, it can in rare circumstances receive the remote op message(s) originating from the other client before the reconnecting client receives the document open confirmation.

It results in the document version going out of sync in the reconnecting client and general odd behaviour from then on.

Inserts will mostly continue working as normal, delete will not work, some ops will be outright rejected depending on which part of a text subdocument they are trying to edit and whether or not it conflicts with the remote ops that were applied during the open phase. While the server document remains in "good condition" after this happens, the client document will corrupt itself more and more until the user realises something is wrong and reloads the page. Not ideal.

Thankfully I was able to write a test that does verify that the fix works, so with the fix the tests should pass, if you git revert 64803f0 and run the tests again, they should fail.

If you want to verify the fix within the application it's quite involved so let me know and I can give a demo.

It no longer applies ops while the @State is "opening", instead
any remote ops received get put into a queue which gets replayed
once we get the open success message back from the server.
Essentially a regression test to make sure we don't break the fix
for how remote ops should be applied after reopening a document
with pending ops that haven't been acknowledged by the server yet.
Copy link

@tomharrold tomharrold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nickbrowne ran me through it, good to go 🚢

@nickbrowne nickbrowne merged commit 72debf9 into master Mar 27, 2024
1 check passed
@nickbrowne nickbrowne deleted the 16461-fix-remote-op-apply-during-open-phase branch March 27, 2024 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants