From 37b71c17b75e664929b5e4aae5f437718c37ae43 Mon Sep 17 00:00:00 2001 From: Adam Horodyski Date: Wed, 5 Jun 2024 09:43:33 +0200 Subject: [PATCH 1/3] fix: call net info refresh on each reachability check --- src/libs/NetworkConnection.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libs/NetworkConnection.ts b/src/libs/NetworkConnection.ts index b3dd24fcd4ae..159747b8aad9 100644 --- a/src/libs/NetworkConnection.ts +++ b/src/libs/NetworkConnection.ts @@ -100,6 +100,9 @@ function subscribeToBackendAndInternetReachability(): () => void { const intervalID = setInterval(() => { // Offline status also implies backend unreachability if (isOffline) { + // Periodically refresh internet reachability check + // More info: https://github.com/Expensify/App/issues/42988 + NetInfo.refresh(); return; } // Using the API url ensures reachability is tested over internet From ba755e68d9c210a8af66a8e128c74cba82a6cd83 Mon Sep 17 00:00:00 2001 From: Adam Horodyski Date: Wed, 5 Jun 2024 12:56:31 +0200 Subject: [PATCH 2/3] chore: add a temporary server log to see the refresh happening --- src/libs/NetworkConnection.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libs/NetworkConnection.ts b/src/libs/NetworkConnection.ts index 159747b8aad9..c1faa2e3b6dc 100644 --- a/src/libs/NetworkConnection.ts +++ b/src/libs/NetworkConnection.ts @@ -102,7 +102,9 @@ function subscribeToBackendAndInternetReachability(): () => void { if (isOffline) { // Periodically refresh internet reachability check // More info: https://github.com/Expensify/App/issues/42988 - NetInfo.refresh(); + NetInfo.refresh().then(() => { + Log.info(`[NetworkStatus] Refreshing NetInfo's network status with "isOffline" set to "true" to double-check internet reachability.`); + }); return; } // Using the API url ensures reachability is tested over internet From bd22f9777ad18d2eb25ba42ceac6f9926ccf3c8c Mon Sep 17 00:00:00 2001 From: Adam Horodyski Date: Thu, 6 Jun 2024 13:08:26 +0200 Subject: [PATCH 3/3] chore: run the existing recheckNetworkConnection check function --- src/libs/NetworkConnection.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/libs/NetworkConnection.ts b/src/libs/NetworkConnection.ts index c1faa2e3b6dc..32dee340c6e6 100644 --- a/src/libs/NetworkConnection.ts +++ b/src/libs/NetworkConnection.ts @@ -100,11 +100,10 @@ function subscribeToBackendAndInternetReachability(): () => void { const intervalID = setInterval(() => { // Offline status also implies backend unreachability if (isOffline) { - // Periodically refresh internet reachability check + // Periodically recheck the network connection // More info: https://github.com/Expensify/App/issues/42988 - NetInfo.refresh().then(() => { - Log.info(`[NetworkStatus] Refreshing NetInfo's network status with "isOffline" set to "true" to double-check internet reachability.`); - }); + recheckNetworkConnection(); + Log.info(`[NetworkStatus] Rechecking the network connection with "isOffline" set to "true" to double-check internet reachability.`); return; } // Using the API url ensures reachability is tested over internet