Skip to content

Commit 6e8785d

Browse files
committed
refactor: explicitly handle errors in the updateChecker function
1 parent 8907351 commit 6e8785d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

CodePush.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,19 @@ async function checkForUpdate(deploymentKey = null, handleBinaryVersionMismatchC
9090
log(`An error has occurred at update checker : ${error.stack}`);
9191
if (sharedCodePushOptions.fallbackToAppCenter) {
9292
return await sdk.queryUpdateWithCurrentPackage(queryPackage);
93+
} else {
94+
// update will not happen
95+
return undefined;
9396
}
9497
}
9598
})()
9699
: await sdk.queryUpdateWithCurrentPackage(queryPackage);
97100

98-
const fileName = update && typeof update.downloadUrl === 'string' ? update.downloadUrl.split('/').pop() : null;
99-
if (sharedCodePushOptions.bundleHost && fileName) {
100-
update.downloadUrl = sharedCodePushOptions.bundleHost + fileName;
101+
if (sharedCodePushOptions.bundleHost && update) {
102+
const fileName = typeof update.downloadUrl === 'string' ? update.downloadUrl.split('/').pop() : null;
103+
if (fileName) {
104+
update.downloadUrl = sharedCodePushOptions.bundleHost + fileName;
105+
}
101106
}
102107

103108
/*

0 commit comments

Comments
 (0)