Skip to content

fix: verify remote document saves after reconnecting - #418

Open
ErlebnisW wants to merge 1 commit into
overleaf-workshop:masterfrom
ErlebnisW:pr/reliable-remote-saves
Open

ErlebnisW wants to merge 1 commit into
overleaf-workshop:masterfrom
ErlebnisW:pr/reliable-remote-saves

Conversation

@ErlebnisW

Copy link
Copy Markdown

Summary

  • prefer the project-aware Socket.IO handshake while retaining the legacy fallback
  • serialize remote document writes, refresh stale OT state, and retry one reconnect
  • re-read the server snapshot and reject a save that the server did not confirm
  • notify the virtual file system when OT versions diverge instead of leaving stale caches silent
  • add focused unit tests for three-way merging and OT update generation

Problem

When the collaboration socket becomes stale or the cached OT version diverges, a remote document write can time out or return without updating the server. The editor may then appear clean even though the remote document still contains the old content.

This change makes a save successful only after a fresh server snapshot matches the merged document. It also reconnects before writing when the underlying Socket.IO transport is disconnected.

Addresses #399.

Validation

  • npm run compile
  • npm run lint (passes with two pre-existing warnings)
  • npm run test:unit (2 passing)
  • forced-disconnect round trip against Overleaf Cloud: the first save reconnected and matched a fresh server snapshot
  • concurrent three-document save round trip: all writes and restorations matched fresh server snapshots

Compatibility

The legacy v1 handshake remains available as a fallback. The reconnect path has been exercised against Overleaf Cloud; a self-hosted server that requires v1 was not available for manual testing.

Prefer the project-aware handshake and serialize remote document writes.

Refresh stale OT state, retry one reconnect, and verify the server snapshot before success.

Constraint: Preserve concurrent remote edits through the existing three-way merge.

Rejected: Trust the local save result | it can succeed after the OT cache has gone stale.

Confidence: high

Scope-risk: moderate

Directive: Keep remote confirmation mandatory for remote document writes.

Tested: TypeScript build, ESLint, OT unit tests, disconnect and multi-file round trips.

Not-tested: Self-hosted servers that require the legacy v1 handshake.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant