Skip to content

fix(collab): skip live-doc registration grace when the direct connection timed out#61

Open
devYRPauli wants to merge 1 commit into
EveryInc:mainfrom
devYRPauli:fix/direct-connection-timeout-grace
Open

fix(collab): skip live-doc registration grace when the direct connection timed out#61
devYRPauli wants to merge 1 commit into
EveryInc:mainfrom
devYRPauli:fix/direct-connection-timeout-grace

Conversation

@devYRPauli

Copy link
Copy Markdown

Problem

loadCanonicalYDoc({ liveRequired: true }) bounds the openDirectConnection
attempt with COLLAB_DIRECT_CONNECTION_TIMEOUT_MS, but when that attempt times
out 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 roughly
direct-timeout + 1500ms to return instead of bailing promptly, defeating the
purpose 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 timedOut flag from
getOrLoadHocuspocusDoc and skip the registration grace when the direct
connection 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 (patches
openDirectConnection to stall, sets a 50ms direct timeout, expects the load to
return null in under 1000ms) now passes; it previously took ~1570ms.

…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).
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