Skip to content

Commit 7fa8a23

Browse files
committed
Add a 1 second timeout for an edge case when the network path does not return.
1 parent b5c2869 commit 7fa8a23

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

WooCommerce/Classes/Tools/BackgroundTasks/BackgroundTaskRefreshDispatcher.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,13 @@ private struct BackgroundTaskSystemInfo {
189189
monitor.cancel()
190190
}
191191

192+
let timeoutTask = Task {
193+
try await Task.sleep(nanoseconds: 1 * NSEC_PER_SEC)
194+
continuation.finish()
195+
}
196+
192197
if let path = await stream.first(where: { _ in true }) {
198+
timeoutTask.cancel()
193199
return NetworkInfo(path: path)
194200
} else {
195201
// Fallback in case no path is received.

0 commit comments

Comments
 (0)