Skip to content

fix: reconnect to the service automatically and restore the VPN - #10

Merged
ethanndickson merged 1 commit into
mainfrom
reconnect-zwg8
Nov 3, 2026
Merged

ethanndickson merged 1 commit into
mainfrom
reconnect-zwg8

Conversation

@ethanndickson

Copy link
Copy Markdown
Member

When rebuild-nix restarted coder-desktop.service today, the app tried to reconnect once, hit the old service whilst it was still shutting down, and gave up. I had to click "Reconnect now", and then turn Coder Connect back on, since the restart had stopped the tunnel too.

To fix, RpcController now keeps the service connection for the life of the app. After a failed attempt or a dropped connection, it tries again after 1 second, doubling the wait up to 5 seconds, with no limit on attempts. "Reconnect now" just skips the wait, and the disconnected page shows the last error. The same loop handles startup, so UnixSocketClientTransport goes back to a single connect attempt instead of waiting for the socket itself, and its test goes with it.

The app also remembers whether the VPN should be on: the "Connect on launch" setting at first, then whatever you last chose. After each reconnect, if the VPN should be on but the service says it's stopped, the app starts it again. If the service rejects the start, or the credentials aren't valid, it forgets, so we don't keep retrying a start that can't work. This replaces the separate "Connect on launch" code in App.axaml.cs.

Speaker.SendRequestAwaitReply now throws when the connection closes before the reply arrives. Previously it waited until the speaker was disposed, so a VPN start that was in flight when the service died would hang and hold the controller's lock.

Two caveats. The app now loads credentials before it connects to the service, so if the deployment is slow to respond at launch, the connection can start up to 15 seconds later. There's also no test project for the app, so the loop has no tests in the repo; I checked it by hand against a fake service.

@ethanndickson
ethanndickson marked this pull request as ready for review November 3, 2026 00:42
@ethanndickson
ethanndickson added this pull request to the merge queue Nov 3, 2026
Merged via the queue into main with commit 7a82155 Nov 3, 2026
1 check passed
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