Open History to see the last commit
1diff --git a/ios/NetworkModule.swift b/ios/NetworkModule.swift
2--- a/ios/NetworkModule.swift
3+++ b/ios/NetworkModule.swift
4@@ -93,10 +93,18 @@
5 // since we want to wait for the result to be updated once:
6 let tempMonitor = NWPathMonitor()
7 var tempPath: NWPath?
8+ let pathLock = NSLock()
10 let semaphore = DispatchSemaphore(value: 0)
12 tempMonitor.pathUpdateHandler = { updatedPath in
13+ // Cancellation does not drain queued updates. Publish only the first path
14+ // and synchronize its retain with the caller reading it on another queue.
15+ pathLock.lock()
16+ defer { pathLock.unlock() }
17+ guard tempPath == nil else {
18+ return
19+ }
20 tempPath = updatedPath
21 semaphore.signal() // Notify that we got the path
22 }
23@@ -114,6 +122,8 @@
24 return nil
25 }
27+ pathLock.lock()
28+ defer { pathLock.unlock() }
29 return tempPath
30 }