Repository navigation
fix(serving): a stream that can't reconcile backs off instead of reconnecting every half second - #780
Merged
Merged
Conversation
…nnecting every half second The shell reset its reconnect backoff on every `hello`. A stream whose subscription POSTs keep failing, misrouted or rate limited, gets a fresh `hello` on each reconnect, so it reopened every 250-500 ms forever. The backoff now starts over only when a stream reconciles, the boundary that already re-arms #776's immediate reconnect. The refresh budget still resets on `hello`, which proves the session was accepted. Closes #777 Co-Authored-By: Claude Opus 5.5 <[email protected]>
A stream that admits its replace while its answers are held hasn't reconciled, so losing it keeps the grown delay; the next stream that gets its answers starts the streak over. Resetting on `admitted` now fails. Co-Authored-By: Claude Opus 5.5 <[email protected]>
allisonmahmood
added a commit
that referenced
this pull request
Oct 19, 2026
…ng Reconnecting (#783) Release 14's What's new entry, written from \`7694bab\`. It covers everything merged since release 13's \`through\` (\`c9b8fc4\`), and sets the \`patchy\` release to \`0.14.0\` (\`packages/patchy/package.json\` and \`CURRENT_RELEASE\`). | Change | PRs | | --- | --- | | Improved: Tools with server code answer faster | #756, #764, #768, #769, #771, #772, #773, #775, #778 | | Improved: Your company's tools and pages open sooner | #759, #761, #766, #770 | | Fixed: Tools stop flashing Reconnecting while they load | #755, #776, #780 | | Improved: Publishing is quicker | #729 | | Improved: New tools start with a tidy layout | #763 | | Improved: Your usual is easier to scan | #721 | | Fixed: A page that isn't there says what to do | #762 | | Fixed: A logo Patchy can't read is refused, not a crash | #728 | | Behind the scenes: richer logs for live data | #758 | #720 is release 13's own entry, so it's left out. Made by Claude Opus 5.5 via Claude Code. Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
The shell reset its reconnect backoff on every
hello. When a host accepts a document's stream but every subscription POST fails, each reconnect gets a freshhello, so the delay never got past its first step. This happens with a persistent misroute (the POSTs are refused as a current-generation loss) or a429on every POST. A document that couldn't reconcile reopened its stream every 0.25–0.5 s for as long as it stayed open, and each reopen cost the server a stream open and a resolve.Fix
reconciledstate: the latest sequence is admitted and every subscription is answered. It's the same boundary that re-arms perf(serving): a stream lost to a misrouted subscription reconnects at once #776's immediate reconnect. Ahelloonly proves the GET landed somewhere.hello. Ahelloproves the refreshed session was accepted, and that's what the budget guards. Moving the reset to reconciliation would let a long unreconciled streak use up the three refreshes across ordinary token expiries. The stream would then stop refreshing and loop on401s.Tests
stream.spec.tsruns with the page clock paused. An init script records the page clock at each stream open and at each abort, so every reconnect delay is exact. The test sorts each delay into its backoff step: the nth failure in a row waits between 250·2ⁿ and 500·2ⁿ ms.409 invalid_request); a stream admitted with its answers held is lost; one reconciles; misrouted again429; a stream admitted with its answers held is lost; one reconciles;429again429streakThe step after the admitted stream (4, not 0) pins the boundary: resetting on
admittedrather than on reconciliation fails both scenario tests.All three fail on main and pass here. The session test also checks that:
#776's tests and the existing session tests are unchanged and pass.
pnpm verifypasses locally: format, lint, typecheck, synth, the offline tests, postgres-concurrency, cli-smoke, tier2-smoke and browser (80 tests). The new tests and #776's main test also passed 5 runs each. The follow-up test commit passes the stream spec (28 tests) andpnpm check.Numbers
Setup:
RuntimeStream.updatethat refused every subscription POST;StreamReplaced(misroute)RateLimited(429)Over 150 s of misroute on this branch, the gaps reach the cap: 17.0, 19.4, 15.1, 24.1 and 25.6 s. Without the hook, Kudos and New Business (tier 2) each open one stream and their POSTs return
200.Closes #777
Made by Claude Opus 5.5 via Claude Code; reviewed with GPT-6.1-Sol.