fix(vfs): do not send an empty applyOtUpdate on save - #408
Open
RobertoReale wants to merge 1 commit into
Open
Conversation
When a document is saved without any real change, the computed diff has an empty `op` array. The update is still sent, and the real-time service answers with an error object and force-disconnects the client shortly after, so the user sees `Unable to write file ... ([object Object])` followed by a reconnection loop. `isDirty` already records whether the update carries any operation: use it to skip the round-trip entirely. The local/remote caches are updated as before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #403
Problem
VirtualFileSystem.writeFilesends the computed OT update unconditionally:When the diff resolves to nothing (saving a document that did not really change),
update.opis[]and the update is still emitted. The real-time service answers the emit with an error object and sendsforceDisconnectshortly after, so:Failed to save 'main.tex': Unable to write file ... ([object Object]);Change
Skip the round-trip when the update carries no operation, reusing the
isDirtyflag computed on the line above. The local and remote caches are updated exactly as before, so a save with no changes is now a silent no-op.Verification
Against overleaf.com with 0.15.10 + this patch: repeated
Ctrl+Son an unchanged document no longer produces an error or a disconnect, and a save that does change the text still reaches the server (applyOtUpdate→ack→otUpdateApplied, text updated live on overleaf.com).