Skip to content

fix(client)!: settle first loads according to the reconnect policy - #66

Open
grrowl wants to merge 1 commit into
mainfrom
fix/first-load-retry-lifecycle
Open

grrowl wants to merge 1 commit into
mainfrom
fix/first-load-retry-lifecycle

Conversation

@grrowl

@grrowl grrowl commented Nov 18, 2026

Copy link
Copy Markdown
Owner

A route awaiting its first snapshot can hang when the server accepts a WebSocket and then closes it with 4403 org access denied. Conversely, failing the first dial on TanStack DB 1.0 ends the sync run even when the transport is already retrying.

This implements ADR-0029. Pending reads wait through automatic retries. When the policy gives up, eager preloads and pending subsets reject with TransportStoppedError, including the close details or underlying cause. An explicit close() pauses registered reads, so a remount can finish the original load. Ready collections keep their rows and registrations for catch-up. The pre-1.0 first-dial failure signal is preserved.

Breaking change and migration

Apps that refresh credentials in onClosed and then call connect() need to restart a first load that already rejected. For transparent recovery, the app can allow a retry for its expiry code and have the socket opener await fresh credentials. The README includes an example of both expiry and permanent denial.

Verification

  • A real workerd accept-then-close test reproduced the hanging preload on the base commit. Integration tests cover terminal denial, credential refresh, and denial after an intentional pause during the first handshake.
  • Typecheck and the full test suite passed locally on @tanstack/db 0.8.6, 0.9.2, and 1.0.0-rc.1.5.
  • Package build, consumer typechecks, and workerd SSR boot passed at the supported floor and locked version.

Keep reads registered across retryable outages and intentional pauses. Surface a terminal policy decision to pending loads and retain usable rows for a subsequent catch-up.

Co-Authored-By: OpenAI Codex <noreply@openai.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