Skip to content

[Fix] Prevent OT op-too-long desync in code editor#1966

Merged
kpal81xd merged 4 commits intomainfrom
fix/ot-op-too-long-desync
Mar 19, 2026
Merged

[Fix] Prevent OT op-too-long desync in code editor#1966
kpal81xd merged 4 commits intomainfrom
fix/ot-op-too-long-desync

Conversation

@kpal81xd
Copy link
Copy Markdown
Contributor

What's Changed

  • Guard applyToShareDb against offset exceeding document length, emitting an error instead of sending an invalid op
  • Resync Monaco editor content after a ShareDB rollback+fetch cycle via doc.on('load')
  • Clear stale undo/redo history on disconnect and after resync to prevent replaying pre-rollback edits
  • Clear document errors on reconnect (realtime:authenticated) so the editor exits read-only mode
  • Listen for documents:error:cleared in document.ts to refresh readonly state

Checks

Guard against offset exceeding document length, resync monaco after
rollback+fetch, clear stale undo/redo on disconnect, and reset document
errors on reconnect so the editor exits read-only mode.
@kpal81xd kpal81xd self-assigned this Mar 19, 2026
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
editor Ready Ready Preview, Comment Mar 19, 2026 11:44am

Request Review

Remove the realtime:disconnected handler that blanket-cleared all
undo/redo stacks. Clean reconnects already OT-transform stacks via
onInsert/onRemove, and rollback reconnects already clear stacks in
doc.on('load'). Also batch documents:error:cleared emit on reconnect.
…socket detection

Restore asset error guard when connected, remove keep-alive pause/resume,
and inline keep-alive setup back into _onauth. Keeps zombie socket
detection on visibility change and event name fix from #1965.
@kpal81xd kpal81xd added bug Something isn't working area: code editor labels Mar 19, 2026
@kpal81xd kpal81xd merged commit 9d15348 into main Mar 19, 2026
9 checks passed
@kpal81xd kpal81xd deleted the fix/ot-op-too-long-desync branch March 19, 2026 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: code editor bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant