Retry session registration instead of killing the daemon - #131
Merged
Conversation
`ensure_registered_now` failed on the first error, and the daemon startup path propagates that with `?` — so a single stalled registration takes the whole daemon down. Control-plane writes routinely stall past this client's 10s request timeout under load, so this fires in normal operation, not just during outages. The cost is worse than a lost daemon: the next start derives a fresh session id from a fresh session file, so every death also strands an empty session in the user's catalog. One machine accumulated 23 sessions in 3.3 hours, 21 of them empty. Retry up to 5 times with exponential backoff (2s, capped at 30s), and report the recovery when a later attempt succeeds. The per-flush registration path is unchanged — it already retries on the next flush. 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.
Problem
ensure_registered_nowfailed on the first error, and the daemon startup path propagates it with?— so one stalled registration takes the whole daemon down.This is not an outage-only path. Control-plane writes routinely stall past this client's 10s request timeout under load. Observed live while testing a single turn:
The knock-on cost is worse than a lost daemon: the next start derives a fresh session id from a fresh session file, so every death also strands an empty session in the user's catalog. One machine accumulated 23 sessions in 3.3 hours, 21 of them empty.
Change
Retry registration up to 5 times with exponential backoff (2s, doubling, capped at 30s), reporting recovery when a later attempt succeeds. The per-flush registration path is untouched — it already retries naturally on the next flush.
This is the client-side half. The server-side half (hi writes currently ride a full control-plane store save) is tracked separately.
Tests
cargo test -p hi --bins— 186 passed.🤖 Generated with Claude Code