fix(client): clear connectPromise and re-arm reconnect on failed open#5
Open
grrowl wants to merge 1 commit into
Open
fix(client): clear connectPromise and re-arm reconnect on failed open#5grrowl wants to merge 1 commit into
grrowl wants to merge 1 commit into
Conversation
A socket that never opens fires no close event, so the close-handler recovery path could not run. The cached rejected connectPromise persisted forever, wedging the transport after any transient outage longer than reconnectDelayMs. Attach a side .catch() to the async IIFE: on rejection, clear connectPromise so the next connect() starts fresh, and re-arm the timer while subscriptions are live. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Executes plan 002 from the advisor audit. Fixes a permanent-wedge bug found in the deep audit.
Why
If a reconnect attempt's
open()rejects (server unreachable when the retry timer fires), the rejectedconnectPromisewas cached forever — a never-opened socket fires no close event, so the "retries on the following close" path never ran. One transient outage >reconnectDelayMsbricked the transport until page reload.What
A side
.catchon the connect IIFE (src/client/transport.ts): clears the cached rejection and re-armsscheduleReconnect()while subscriptions are live and the close wasn't intentional. Rejection still propagates to demand-path callers (fail-loud preserved). No backoff added — that deferral stands per the file's own comment.Verification
TDD: both new tests in
tests/reconnect-recovery.test.tsdemonstrably failed pre-fix (timeout / cached rejection), pass post-fix.reconnect-window.test.ts(the demand-driven-connect invariant) stays green. Reviewer independently audited the double-scheduling risk: coalesced by the existingthis.ws/ cached-promise guards.🤖 Generated with Claude Code