fix(installer): retry installer when hitting ETIMEDOUT as well (#5239)

Fixes #5233
This commit is contained in:
Andrey Lushnikov 2021-02-01 09:30:22 -08:00 committed by GitHub
parent 7b5363198b
commit 08e2b5b825
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -137,7 +137,8 @@ export async function downloadBrowserWithProgressBar(browsersPath: string, brows
const {error} = await downloadFile(url, zipPath, progress);
if (!error)
break;
if (attempt < N && error && typeof error === 'object' && typeof error.message === 'string' && error.message.includes('ECONNRESET')) {
const errorMessage = typeof error === 'object' && typeof error.message === 'string' ? error.message : '';
if (attempt < N && (errorMessage.includes('ECONNRESET') || errorMessage.includes('ETIMEDOUT'))) {
// Maximum delay is 3rd retry: 1337.5ms
const millis = (Math.random() * 200) + (250 * Math.pow(1.5, attempt));
await new Promise(c => setTimeout(c, millis));