Skip to content

Retry every client connection failure; make long outages cheap - #103

Merged
andrewchen5678 merged 2 commits into
mainfrom
client-reconnect-revamp
Sep 16, 2026
Merged

andrewchen5678 merged 2 commits into
mainfrom
client-reconnect-revamp

Conversation

@andrewchen5678

Copy link
Copy Markdown
Contributor

Summary

  • The CLI client no longer exits when its first connection attempt fails on a transient error. A failed attempt is retried exactly like a lost connection; only permanent errors (rejected key, bad config, proxy port in use) end the session. --no-auto-reconnect and --max-reconnect-attempts keep their names but now cover the first attempt too.
  • Long outages are cheap: backoff cap raised from 60s to 5 min, and the endpoint rebuild still fires after the third consecutive failure but then repeats at most every 30 min per outage instead of on every third attempt.
  • On iOS, the app coming to the foreground ends a backoff wait immediately with a fresh series, as a restored network path already did.
  • The reconnect loop publishes failed attempts, last error, and next attempt time; the CLI status snapshot carries it and the control panel shows it on the phase line.
  • Docs, config example, flag help, and FFI comments updated. Version bumped to 0.0.79.

Test plan

  • ci/unix/ci.sh (clippy -D warnings + core and CLI tests) green; workspace clippy including desktop clean
  • New unit tests: backoff cap, rebuild gating, first-failure retry, retry cap, foreground wake, parked wait ignores foreground
  • New hermetic e2e test: client started against a server that rejects until a late-start signal survives and connects
  • Live runs with the built binaries: client started before server waits through a 30s connect timeout and connects when the server appears; SIGKILLed server is detected and reconnected on restart with proxy traffic flowing both times; --no-auto-reconnect and --max-reconnect-attempts 1 exit nonzero as documented; unauthorized key exits immediately without retry
  • ./build-ios.sh release rebuilt the xcframework on the Mac VM

🤖 Generated with Claude Code

Andrew Chen and others added 2 commits September 15, 2026 17:53
The CLI client used to exit when its first connection attempt failed,
even for transient errors, so a client started before its server (or
against a server down for maintenance) died instead of waiting. The
reconnect loop now treats a failed attempt exactly like a lost
connection: only permanent errors (rejected key, bad config, proxy port
in use) end the session. auto_reconnect=false and max_reconnect_attempts
keep their names but now cover the first attempt too.

Long outages no longer cost much: the backoff cap rises from 60s to
5 min, and the endpoint rebuild still fires after the third consecutive
failure but then repeats at most every 30 min per outage instead of on
every third attempt. On iOS, the app coming to the foreground ends a
backoff wait immediately with a fresh series, as a restored network path
already did.

The loop publishes its retry state (failed attempts, last error, next
attempt time); the CLI status snapshot carries it and the control panel
shows it on the phase line. Docs, config example, flag help, and FFI
comments updated; unit and e2e tests cover the new policy.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@andrewchen5678
andrewchen5678 merged commit 29fc739 into main Sep 16, 2026
4 checks passed
@andrewchen5678
andrewchen5678 deleted the client-reconnect-revamp branch September 16, 2026 01:10
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