diff --git a/src/libs/NetworkConnection.ts b/src/libs/NetworkConnection.ts index acdb982c729a..d38fd4118cfd 100644 --- a/src/libs/NetworkConnection.ts +++ b/src/libs/NetworkConnection.ts @@ -112,6 +112,7 @@ function subscribeToNetInfo(): () => void { reachabilityUrl: `${CONFIG.EXPENSIFY.DEFAULT_API_ROOT}api/Ping?accountID=${accountID || 'unknown'}`, reachabilityMethod: 'GET', reachabilityTest: (response) => { + hasPendingNetworkCheck = false; if (!response.ok) { return Promise.resolve(false); } @@ -123,6 +124,13 @@ function subscribeToNetInfo(): () => void { // If a check is taking longer than this time we're considered offline reachabilityRequestTimeout: CONST.NETWORK.MAX_PENDING_TIME_MS, + reachabilityShouldRun: () => { + if (hasPendingNetworkCheck) { + return false; + } + hasPendingNetworkCheck = true; + return true; + }, }); } @@ -196,8 +204,7 @@ function recheckNetworkConnection() { } Log.info('[NetworkConnection] recheck NetInfo'); - hasPendingNetworkCheck = true; - NetInfo.refresh().finally(() => (hasPendingNetworkCheck = false)); + NetInfo.refresh(); } export default {