From 76912ff61dad8dbccec160425899037a4c2c5edb Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 4 May 2023 16:29:10 -0700 Subject: [PATCH 1/3] Use Ping endpoint for internet reachability instead of API root --- package-lock.json | 11 +++++++---- package.json | 2 +- src/libs/NetworkConnection.js | 12 ++++++++++-- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4431b10d659..91baaaf258b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,7 +22,7 @@ "@react-native-camera-roll/camera-roll": "5.4.0", "@react-native-community/clipboard": "^1.5.1", "@react-native-community/datetimepicker": "^3.5.2", - "@react-native-community/netinfo": "^8.3.0", + "@react-native-community/netinfo": "^9.3.9", "@react-native-community/progress-bar-android": "^1.0.4", "@react-native-community/progress-view": "^1.2.3", "@react-native-firebase/analytics": "^12.3.0", @@ -7034,8 +7034,9 @@ "license": "MIT" }, "node_modules/@react-native-community/netinfo": { - "version": "8.3.1", - "license": "MIT", + "version": "9.3.9", + "resolved": "https://registry.npmjs.org/@react-native-community/netinfo/-/netinfo-9.3.9.tgz", + "integrity": "sha512-L9f8OjX5Fwh5CdP4ygDPa6iQCJJ4tAtXiFuQp6EG4/sdSXDqOXaehAhJrZAN8P8Lztnf8YN8p836GmZuBCrY+A==", "peerDependencies": { "react-native": ">=0.59" } @@ -46102,7 +46103,9 @@ "dev": true }, "@react-native-community/netinfo": { - "version": "8.3.1", + "version": "9.3.9", + "resolved": "https://registry.npmjs.org/@react-native-community/netinfo/-/netinfo-9.3.9.tgz", + "integrity": "sha512-L9f8OjX5Fwh5CdP4ygDPa6iQCJJ4tAtXiFuQp6EG4/sdSXDqOXaehAhJrZAN8P8Lztnf8YN8p836GmZuBCrY+A==", "requires": {} }, "@react-native-community/progress-bar-android": { diff --git a/package.json b/package.json index f5b0ff64efe..4d57b1cbfcc 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "@react-native-camera-roll/camera-roll": "5.4.0", "@react-native-community/clipboard": "^1.5.1", "@react-native-community/datetimepicker": "^3.5.2", - "@react-native-community/netinfo": "^8.3.0", + "@react-native-community/netinfo": "^9.3.9", "@react-native-community/progress-bar-android": "^1.0.4", "@react-native-community/progress-view": "^1.2.3", "@react-native-firebase/analytics": "^12.3.0", diff --git a/src/libs/NetworkConnection.js b/src/libs/NetworkConnection.js index 66f62a862b0..ca76c1cbc39 100644 --- a/src/libs/NetworkConnection.js +++ b/src/libs/NetworkConnection.js @@ -78,8 +78,16 @@ function subscribeToNetInfo() { // By default, NetInfo uses `/` for `reachabilityUrl` // When App is served locally (or from Electron) this address is always reachable - even offline // Using the API url ensures reachability is tested over internet - reachabilityUrl: `${CONFIG.EXPENSIFY.DEFAULT_API_ROOT}api`, - reachabilityTest: response => Promise.resolve(response.status === 200), + reachabilityUrl: `${CONFIG.EXPENSIFY.DEFAULT_API_ROOT}api?command=Ping`, + reachabilityMethod: 'GET', + reachabilityTest: (response) => { + if (!response.ok) { + return Promise.resolve(false); + } + return response.json() + .then(json => Promise.resolve(json.jsonCode === 200)) + .catch(() => Promise.resolve(false)); + }, // If a check is taking longer than this time we're considered offline reachabilityRequestTimeout: CONST.NETWORK.MAX_PENDING_TIME_MS, From 508cad78c6fa02e6b341993b7bd61d9a185131d3 Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 4 May 2023 17:06:00 -0700 Subject: [PATCH 2/3] Update Podfile.lock --- ios/Podfile.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index e81f2d2c640..6bc6ebfdbbf 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -516,7 +516,7 @@ PODS: - React-Core - react-native-key-command (1.0.0): - React-Core - - react-native-netinfo (8.3.1): + - react-native-netinfo (9.3.9): - React-Core - react-native-pdf (6.6.2): - React-Core @@ -1014,7 +1014,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: Airship: c70eed50e429f97f5adb285423c7291fb7a032ae AirshipFrameworkProxy: 2eefb77bb77b5120b0f48814b0d44439aa3ad415 - boost: a7c83b31436843459a1961bfd74b96033dc77234 + boost: 57d2868c099736d80fcd648bf211b4431e51a558 CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54 FBLazyVector: ff54429f0110d3c722630a98096ba689c39f6d5f @@ -1057,7 +1057,7 @@ SPEC CHECKSUMS: Permission-LocationWhenInUse: 3ba99e45c852763f730eabecec2870c2382b7bd4 Plaid: 7d340abeadb46c7aa1a91f896c5b22395a31fcf2 PromisesObjC: 09985d6d70fbe7878040aa746d78236e6946d2ef - RCT-Folly: 0080d0a6ebf2577475bda044aa59e2ca1f909cda + RCT-Folly: 424b8c9a7a0b9ab2886ffe9c3b041ef628fd4fb1 RCTRequired: e9e7b8b45aa9bedb2fdad71740adf07a7265b9be RCTTypeSafety: 9ae0e9206625e995f0df4d5b9ddc94411929fb30 React: a71c8e1380f07e01de721ccd52bcf9c03e81867d @@ -1080,7 +1080,7 @@ SPEC CHECKSUMS: react-native-image-manipulator: c48f64221cfcd46e9eec53619c4c0374f3328a56 react-native-image-picker: c33d4e79f0a14a2b66e5065e14946ae63749660b react-native-key-command: 0b3aa7c9f5c052116413e81dce33a3b2153a6c5d - react-native-netinfo: 1a6035d3b9780221d407c277ebfb5722ace00658 + react-native-netinfo: 22c082970cbd99071a4e5aa7a612ac20d66b08f0 react-native-pdf: 33c622cbdf776a649929e8b9d1ce2d313347c4fa react-native-performance: 224bd53e6a835fda4353302cf891d088a0af7406 react-native-plaid-link-sdk: 9eb0f71dad94b3bdde649c7a384cba93024af46c From 907802654f517dd72ad49775cbebbe2306175134 Mon Sep 17 00:00:00 2001 From: rory Date: Tue, 9 May 2023 15:20:19 -0700 Subject: [PATCH 3/3] Fix prettier --- src/libs/NetworkConnection.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libs/NetworkConnection.js b/src/libs/NetworkConnection.js index 73761f1bb33..67baec1ad3e 100644 --- a/src/libs/NetworkConnection.js +++ b/src/libs/NetworkConnection.js @@ -87,8 +87,9 @@ function subscribeToNetInfo() { if (!response.ok) { return Promise.resolve(false); } - return response.json() - .then(json => Promise.resolve(json.jsonCode === 200)) + return response + .json() + .then((json) => Promise.resolve(json.jsonCode === 200)) .catch(() => Promise.resolve(false)); },