Skip to content

fix(client): clear connectPromise and re-arm reconnect on failed open#12

Merged
grrowl merged 1 commit into
mainfrom
fix/002-transport-reconnect-recovery
Jun 13, 2026
Merged

fix(client): clear connectPromise and re-arm reconnect on failed open#12
grrowl merged 1 commit into
mainfrom
fix/002-transport-reconnect-recovery

Conversation

@grrowl

@grrowl grrowl commented Jun 13, 2026

Copy link
Copy Markdown
Owner

Lands plan-002's reconnect-wedge fix on main (0.3.2 patch).

Bug (present on main): a WebSocket that never open()s fires no close event, so the close-handler's auto-reconnect can't run. The cached rejected connectPromise then wedges the transport permanently — every later connect() returns the same rejection. The client never recovers from a single failed initial attempt while subscriptions are live.

Fix: on a failed open, clear connectPromise and re-arm the reconnect (inlined, mirroring the existing close-handler) while subscriptions remain. No double-scheduling: a socket that fails to open fires no close, so only this path runs; an opened-then-dropped socket runs only the close handler.

Main-adaptation: inlines the reconnect schedule rather than calling feat/ssr's extracted scheduleReconnect() (which doesn't exist on main).

TDD red→green pinned by tests/reconnect-recovery.test.ts (2 cases). Validated on main + published @tanstack/db 0.6.5: typecheck + full suite (153 passed) + build green. Supersedes feat/ssr PR #5.

🤖 Generated with Claude Code

A socket that never OPENED fires no close event, so the close-handler
recovery can't run; the cached rejected connectPromise then wedges the
transport — every later connect() returns the same rejection. On failed
open, clear it and re-arm the reconnect (inline, mirroring the close
handler) while subscriptions are live.

Adapted for main: inlines the reconnect schedule rather than calling
feat/ssr's extracted scheduleReconnect() (which does not exist on main).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@grrowl grrowl merged commit 805abe2 into main Jun 13, 2026
1 check passed
grrowl added a commit that referenced this pull request Jun 13, 2026
Bug-fix batch from the deep-audit follow-up (audit-excluded SSR topic aside):
client reconnect-wedge fix (#12), wire-input hardening + error sanitization
(#15, ADR-0012), catch-up N+1 batching (#14), plus expanded error/wire test
coverage (#11) and dead-code/identifier-quoting cleanup (#13).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
grrowl added a commit that referenced this pull request Jun 13, 2026
- transport: express the failed-open reconnect recovery (#12) via the
  existing scheduleReconnect() rather than the inline form main carried
  (main had no such method; feat/ssr does) — same behavior, one path.
- regenerate package-lock against the merged package.json (0.4.0-dev.0,
  vendored PR-1564 tarballs).

The 0.3.2 fixes (#11#15) now coexist with the SSR feature: readSyncSnapshot
+ readChangesSinceFor + wire guards in sync-do; highWaterSeq + per-table
indexed reads + quoted trigger DDL in changes; ADR index carries 0011+0012.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
grrowl added a commit that referenced this pull request Jun 13, 2026
- transport: express the failed-open reconnect recovery (#12) via the
  existing scheduleReconnect() rather than the inline form main carried
  (main had no such method; feat/ssr does) — same behavior, one path.
- regenerate package-lock against the merged package.json (0.4.0-dev.0,
  vendored PR-1564 tarballs).

The 0.3.2 fixes (#11#15) now coexist with the SSR feature: readSyncSnapshot
+ readChangesSinceFor + wire guards in sync-do; highWaterSeq + per-table
indexed reads + quoted trigger DDL in changes; ADR index carries 0011+0012.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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