feat(remote): exponential reconnect backoff + classified disconnect reason - #58
Closed
brettchien wants to merge 1 commit into
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>
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.
Studio-review item 2 (reconnect backoff + error classification) and 斷線原因可觀測性, plus the testable slice of item 3.
What
Before: 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, 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 it's covered by the workspace CI gate):backoff_delay(attempt, salt)— exponential 1→2→4→8→16s, capped at 30s, with per-connection jitter (salt = first byte of the connection id).DisconnectReason::classify(&str)+label()— buckets an error into network / auth rejected / server at capacity / protocol / other.remote.rsrun_reconnecting— escalate backoff on consecutive fast failures; reset to 1s once a connection held ≥15s (a real drop retries fast, a bad dial keeps backing off); put the classified reason in the status line (error: server at capacity, …) + the Activity log. The console already renders the status string, so the reason shows up with no frontend change.Tests / verification
cargo test -p acp-tunnel). Session state-machine transitions were already covered inacp-tunnel.cargo check -p acp-tunnelclean.remote.rscompiles underbundle-macosCI (this box has no GTK).Not in this PR (from the review)
🤖 Generated with Claude Code