Skip to content

Commit

Permalink
[native] handle errors when running migration to new flow
Browse files Browse the repository at this point in the history
Summary:
[ENG-10094](https://linear.app/comm/issue/ENG-10094/migration-to-v2-is-not-working-on-non-primary-device).

`getAuthMetadata` can throw and then `backupUploadInProgress` is set to true forever

Depends on D14215

Test Plan: simulate error and check if it thrown

Reviewers: bartek, tomek

Reviewed By: bartek, tomek

Subscribers: ashoat

Differential Revision: https://phab.comm.dev/D14216
  • Loading branch information
xsanm committed Jan 20, 2025
1 parent 72769c2 commit 8c3bf7e
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions native/backup/backup-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,19 @@ function BackupHandler(): null {
void (async () => {
backupUploadInProgress.current = true;

const [isPrimaryDevice, { userID, deviceID }] = await Promise.all([
checkIfPrimaryDevice(),
getAuthMetadata(),
]);
let isPrimaryDevice, userID, deviceID;
try {
const [isPrimaryDeviceResult, authMetadata] = await Promise.all([
checkIfPrimaryDevice(),
getAuthMetadata(),
]);
isPrimaryDevice = isPrimaryDeviceResult;
userID = authMetadata.userID;
deviceID = authMetadata.deviceID;
} catch (e) {
backupUploadInProgress.current = false;
return;
}

// CurrentIdentityUserState is required to check if migration to
// new flow is needed.
Expand Down

0 comments on commit 8c3bf7e

Please sign in to comment.