fix(client): back off reconnects when the stream never connects - #48161
fix(client): back off reconnects when the stream never connects#48161holny wants to merge 1 commit into
Conversation
The event-stream client retried on a fixed one-second delay no matter why the stream died, so an unauthenticated browser session re-triggered the Basic auth prompt every second. Streams that never connected successfully now scale the delay with the attempt count up to 30 seconds; streams that connected and later dropped keep the existing one-second retry.
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: I found a related PR that may be addressing a similar issue: PR #48015: fix(app): back off event stream reconnects after repeated failures This PR also deals with backing off event stream reconnects, but it's scoped to the Note: PR #47204 mentioned in the description as being superseded appears to have had its fork deleted, so it's not showing up in current searches. |
Issue for this PR
Fixes #47062
Type of change
What does this PR do?
The event-stream client retried on a fixed one-second delay regardless of why the stream died, so an unauthenticated browser session re-triggered the Basic auth prompt every second while the shell sat there unauthenticated. Streams that never connected successfully now scale the retry delay with the attempt count up to 30 seconds, which gives the browser prompt time to be answered; streams that connected and later dropped reset the attempt counter and keep the existing one-second retry.
The failure reason is intentionally not inspected — a declared 401 with an empty body surfaces client-side as an indistinguishable
ClientError("UnsupportedContentType"), and the never-connected case is the one that needs the guard regardless of cause.How did you verify your code works?
test/solid-connection.test.ts: a 401-empty-response API under a real clock — reconnect attempts stay monotonically increasing across 400ms and the inter-attempt gaps grow (no backoff would produce ~20 attempts, backoff produces ~7)reconnectBackoffDelayunit cases for scaling, the 30s cap, and the attempt-0 floorbun typecheck+ fullpackages/clientsuite (152 passing)Checklist
Supersedes #47204 — the PR head fork was accidentally deleted on 2026-09-09 (not intentional, see the notification comment there); re-filing so the review can continue. Original conversation: #47204