Skip to content

Commit

Permalink
Merge pull request #9115 from Expensify/update-staging-from-main
Browse files Browse the repository at this point in the history
Update version to 1.1.65-4 on staging
  • Loading branch information
AndrewGable authored May 20, 2022
2 parents 84febb4 + 0451e7e commit c2f38be
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 9 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
versionCode 1001016500
versionName "1.1.65-0"
versionCode 1001016504
versionName "1.1.65-4"
}
splits {
abi {
Expand Down
2 changes: 1 addition & 1 deletion ios/NewExpensify/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1.1.65.0</string>
<string>1.1.65.4</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/NewExpensifyTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.1.65.0</string>
<string>1.1.65.4</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "new.expensify",
"version": "1.1.65-0",
"version": "1.1.65-4",
"author": "Expensify, Inc.",
"homepage": "https://new.expensify.com",
"description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.",
Expand Down
4 changes: 3 additions & 1 deletion src/libs/Middleware/Logging.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ function Logging(response, request) {
if (persisted) {
PersistedRequests.remove(request);
}
return;

// Re-throw this error so the next handler can manage it
throw error;
}

if (error.message === CONST.ERROR.FAILED_TO_FETCH) {
Expand Down
6 changes: 6 additions & 0 deletions src/libs/Middleware/Reauthentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ import Log from '../Log';
function Reauthentication(response, request, isFromSequentialQueue) {
return response
.then((data) => {
// If there is no data for some reason then we cannot reauthenticate
if (!data) {
Log.hmmm('Undefined data in Reauthentication');
return;
}

if (NetworkStore.isOffline()) {
// If we are offline and somehow handling this response we do not want to reauthenticate
throw new Error('Unable to reauthenticate because we are offline');
Expand Down
7 changes: 5 additions & 2 deletions src/libs/Middleware/RecheckConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ function RecheckConnection(response) {
const cancelRequestTimeoutTimer = startRecheckTimeoutTimer();
return response
.catch((error) => {
// Because we ran into an error we assume we might be offline and do a "connection" health test
NetworkConnection.recheckNetworkConnection();
if (error.name !== CONST.ERROR.REQUEST_CANCELLED) {
// Because we ran into an error we assume we might be offline and do a "connection" health test
NetworkConnection.recheckNetworkConnection();
}

throw error;
})
.finally(cancelRequestTimeoutTimer);
Expand Down
5 changes: 5 additions & 0 deletions src/libs/Middleware/Retry.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ function retryFailedRequest(queuedRequest, error) {
function Retry(response, request, isFromSequentialQueue) {
return response
.catch((error) => {
// Do not retry any requests that are cancelled
if (error.name === CONST.ERROR.REQUEST_CANCELLED) {
return;
}

if (isFromSequentialQueue) {
const retryCount = PersistedRequests.incrementRetries(request);
Log.info('Persisted request failed', false, {retryCount, command: request.command, error: error.message});
Expand Down
8 changes: 8 additions & 0 deletions src/libs/Network/MainQueue.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,17 @@ function clear() {
HttpUtils.cancelPendingRequests();
}

/**
* @returns {Array}
*/
function getAll() {
return networkRequestQueue;
}

export {
clear,
replay,
push,
process,
getAll,
};
24 changes: 24 additions & 0 deletions tests/unit/NetworkTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -765,3 +765,27 @@ test('persistable request will move directly to the SequentialQueue when we are
expect(thirdRequestCommandName).toBe('MockCommandTwo');
});
});

test('cancelled requests should not be retried', () => {
const xhr = jest.spyOn(HttpUtils, 'xhr');

// GIVEN a mock that will return a "cancelled" request error
global.fetch = jest.fn()
.mockRejectedValue(new DOMException('Aborted', CONST.ERROR.REQUEST_CANCELLED));

return Onyx.set(ONYXKEYS.NETWORK, {isOffline: false})
.then(() => {
// WHEN we make a few requests and then cancel them
Network.post('MockCommandOne');
Network.post('MockCommandTwo');
Network.post('MockCommandThree');

// WHEN we wait for the requests to all cancel
return waitForPromisesToResolve();
})
.then(() => {
// THEN expect our queue to be empty and for no requests to have been retried
expect(MainQueue.getAll().length).toBe(0);
expect(xhr.mock.calls.length).toBe(3);
});
});

0 comments on commit c2f38be

Please sign in to comment.