Wait for the server's tailnet peer before connecting at app startup

This commit is contained in:
Ian Gulliver
2026-10-20 14:52:10 -07:00
parent a2571763b4
commit a95e0ddb29
5 changed files with 83 additions and 12 deletions
+2 -1
View File
@@ -198,7 +198,7 @@ final class Connection {
private func start() async {
let old = store
while !stopped, !Tailnet.shared.running {
while !stopped, !Tailnet.shared.reachable(origin) {
try? await Task.sleep(for: .milliseconds(500))
}
while !stopped, !(await attempt(old)) {
@@ -252,6 +252,7 @@ final class Connection {
Notifier.shared.deliver()
return true
} catch {
log.notice("connect \(self.origin.absoluteString, privacy: .public) failed: \(errorText(error), privacy: .public); \(tailnetNode.peerState(self.origin.host()!), privacy: .public)")
await store.stop()
if !stopped {
phase = .failed(explain(error, origin))