From 78d31731fc9e4034716085038135e2e680a02613 Mon Sep 17 00:00:00 2001 From: Mattt Zmuda Date: Wed, 24 Sep 2025 06:11:12 -0700 Subject: [PATCH] Seed NetworkMonitor state from currentPath to eliminate startup offline race --- Sources/Hub/HubApi.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sources/Hub/HubApi.swift b/Sources/Hub/HubApi.swift index 59ec26a..47d40b9 100644 --- a/Sources/Hub/HubApi.swift +++ b/Sources/Hub/HubApi.swift @@ -801,6 +801,13 @@ extension HubApi { } monitor.start(queue: queue) + + // Seed initial state immediately to avoid a startup race + // where the default value (`isConnected == false`) + // is read before the first `pathUpdateHandler` callback fires. + Task { + await self.state.update(path: self.monitor.currentPath) + } } func stopMonitoring() {