feat(remote): exponential reconnect backoff + classified disconnect reason - #59
Merged
brettchien merged 1 commit intoAug 15, 2026
Conversation
…eason
The reconnect loop retried on a flat 5s cadence forever and surfaced every
failure as a raw error blob. With the gateway's handful of session slots, a
flapping link hammered it on a fixed beat, and the operator couldn't tell a
network blip from an auth reject or the server being at capacity.
- acp-tunnel: new pure `reconnect` module (unit-tested, no GTK needed):
- `backoff_delay(attempt, salt)` — exponential 1→2→4→8→16s capped at 30s
with per-connection jitter.
- `DisconnectReason::classify(&str)` + `label()` — network / auth rejected
/ server at capacity / protocol / other.
- remote.rs run_reconnecting: escalate backoff on consecutive fast failures,
reset once a connection has held ≥15s, and put the classified reason in the
status line (e.g. "error: server at capacity") + log.
Tests: 3 new reconnect unit tests (classification + backoff shape/cap/jitter);
the Session state machine is already covered in acp-tunnel. The pure policy now
lives in the workspace-tested crate so the Tauri driver stays thin.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
brettchien
deleted the
feat/remote-reconnect-backoff-and-error-classification
branch
August 15, 2026 08:23
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.
Supersedes #58 (auto-closed by GitHub when its stacked base branch
fix/remote-session-graceful-teardownwas deleted on #57's merge). Same change, now rebased ontomain(base =main).Studio-review item 2 (reconnect backoff + error classification), 斷線原因可觀測性, and the testable slice of item 3.
What
The reconnect loop retried on a flat 5s cadence forever and surfaced every failure as a raw error string. With the gateway's small session-slot pool (
max_sessions), a flapping link hammered it on a fixed beat, and the operator couldn't tell a network blip from an auth reject or the server being at capacity.Changes
acp-tunnel— new purereconnectmodule (unit-tested; compiles/tests without GTK so the workspace CI gate covers it):backoff_delay(attempt, salt)— exponential 1→2→4→8→16s, capped 30s, + per-connection jitter.DisconnectReason::classify(&str)+label()— network / auth rejected / server at capacity / protocol / other.remote.rsrun_reconnecting— escalate backoff on consecutive fast failures; reset once a connection held ≥15s; put the classified reason in the status line (error: server at capacity, …) + Activity log. Console renders the status string as-is, so the reason surfaces with no frontend change.Tests / verification
cargo test -p acp-tunnel). Session state-machine already covered inacp-tunnel.remote.rscompiles underbundle-macosCI (no GTK on the authoring box).Not in this PR
🤖 Generated with Claude Code