fix(collab): skip live-doc registration grace when the direct connection timed out#61
Open
devYRPauli wants to merge 1 commit into
Open
Conversation
…ion timed out loadCanonicalYDoc bounds the openDirectConnection attempt with COLLAB_DIRECT_CONNECTION_TIMEOUT_MS, but on timeout it still waited the full COLLAB_LIVE_DOC_REGISTRATION_GRACE_MS (default 1500ms) for a live doc to register - so a stalled direct connection took ~direct-timeout + 1500ms instead of bailing promptly, defeating the bounded timeout. A timed-out direct connection establishes nothing for the live-doc map to register, so propagate a timedOut flag from getOrLoadHocuspocusDoc and skip the registration grace in that case. An already-registered live doc is still returned by the point-in-time check before the grace, so a concurrently present live doc is unaffected. Verified against the existing collab-direct-connection-timeout-regression test (now returns null in well under the bound).
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.
Problem
loadCanonicalYDoc({ liveRequired: true })bounds theopenDirectConnectionattempt with
COLLAB_DIRECT_CONNECTION_TIMEOUT_MS, but when that attempt timesout it still waited the full
COLLAB_LIVE_DOC_REGISTRATION_GRACE_MS(default1500ms) for a live doc to register. So a stalled direct connection took roughly
direct-timeout + 1500msto return instead of bailing promptly, defeating thepurpose of the bounded direct-connection timeout.
Fix
A timed-out direct connection establishes nothing for the live-doc map to
register, so there is nothing to wait for. Propagate a
timedOutflag fromgetOrLoadHocuspocusDocand skip the registration grace when the directconnection timed out. An already-registered live doc is still returned by the
point-in-time check before the grace, so a concurrently present live doc is
unaffected.
Test
src/tests/collab-direct-connection-timeout-regression.test.ts(patchesopenDirectConnectionto stall, sets a 50ms direct timeout, expects the load toreturn
nullin under 1000ms) now passes; it previously took ~1570ms.