Repository navigation
fix: reconnect to the service automatically and restore the VPN - #10
Merged
Merged
Conversation
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.
When
rebuild-nixrestartedcoder-desktop.servicetoday, 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,
RpcControllernow 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, soUnixSocketClientTransportgoes 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.SendRequestAwaitReplynow 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.