Skip to content

Commit 091d6c8

Browse files
committed
Seed NetworkMonitor state from currentPath to eliminate startup offline race
1 parent c5de635 commit 091d6c8

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Sources/Hub/HubApi.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,13 @@ extension HubApi {
801801
}
802802

803803
monitor.start(queue: queue)
804+
805+
// Seed initial state immediately to avoid a startup race
806+
// where the default value (`isConnected == false`)
807+
// is read before the first `pathUpdateHandler` callback fires.
808+
Task {
809+
await self.state.update(path: self.monitor.currentPath)
810+
}
804811
}
805812

806813
func stopMonitoring() {

0 commit comments

Comments
 (0)