Repository navigation
🐛 Stop stale remote presence catch-up looping forever - #745
Merged
Merged
Conversation
alecgibson
commented
Oct 8, 2026
Fixes #732 At the moment, `RemoteDocPresence` ignores errors returned by `ot.transformPresence()` when catching up stale presence. Since `presence.v` isn't advanced on error, the loop never ends: 1. A peer sends a stale presence with `t: null` and no `d` 2. An op is submitted to the doc 3. The peer resends the stale presence 4. The receiving client hangs, freezing the tab This change drops the pending presence and emits the error instead, as we already do in `_transformAgainstOp()`. `ot.transformPresence()` also now returns a `ShareDBError` like the rest of `ot`, since that's what the presence `'error'` event is documented to emit. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
alecgibson
force-pushed
the
fix/issue-732-presence-catch-up-loop
branch
from
October 8, 2026 13:47
030efd7 to
a529e19
Compare
There was a problem hiding this comment.
🟢 Approval recommended
The fix terminates the failing catch-up path and includes focused regression coverage.
0 open findings
What changed in this PR
Prevents infinite stale-presence catch-up loops by handling transformation failures safely.
Changes:
- Drops untransformable pending presence and stops operation caching.
- Returns
ShareDBErrorinstances from presence transformations. - Adds regression coverage for recovery after malformed presence.
| File | Description |
|---|---|
lib/client/presence/remote-doc-presence.js |
Handles catch-up transformation errors. |
lib/ot.js |
Standardizes transformation errors. |
test/client/presence/doc-presence.js |
Tests error emission and recovery. |
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
alecgibson
marked this pull request as ready for review
October 8, 2026 13:57
dawidreedsy
approved these changes
Oct 8, 2026
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 #732
At the moment,
RemoteDocPresenceignores errors returned byot.transformPresence()when catching up stale presence. Sincepresence.visn't advanced on error, the loop never ends:t: nulland nodThis change drops the pending presence and emits the error instead, as we already do in
_transformAgainstOp().ot.transformPresence()also now returns aShareDBErrorlike the rest ofot, since that's what the presence'error'event is documented to emit.🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com