From a31faaae616ba82373f5032fb40292a32031fb60 Mon Sep 17 00:00:00 2001 From: John Kleinschmidt Date: Thu, 30 May 2019 20:22:35 -0400 Subject: [PATCH] ci: add retries to downloads for arm testing (#18526) --- script/download-circleci-artifacts.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/script/download-circleci-artifacts.js b/script/download-circleci-artifacts.js index 484dc15b8fd5..6ae6124a85bf 100644 --- a/script/download-circleci-artifacts.js +++ b/script/download-circleci-artifacts.js @@ -49,11 +49,30 @@ async function downloadArtifact (name, buildNum, dest) { process.exit(1) } else { console.log(`Downloading ${artifactToDownload.url}.`) - await downloadFile(artifactToDownload.url, dest) - console.log(`Successfully downloaded ${name}.`) + let downloadError = false + await downloadWithRetry(artifactToDownload.url, dest).catch(err => { + console.log(`Error downnloading ${artifactToDownload.url} :`, err) + downloadError = true + }) + if (!downloadError) { + console.log(`Successfully downloaded ${name}.`) + } } } +async function downloadWithRetry (url, directory) { + let lastError + for (let i = 0; i < 5; i++) { + console.log(`Attempting to download ${url} - attempt #${(i + 1)}`) + try { + return await downloadFile(url, directory) + } catch (err) { + lastError = err + } + } + throw lastError +} + function downloadFile (url, directory) { return new Promise((resolve, reject) => { const nuggetOpts = {