X Tutup
Skip to content

Commit a31faaa

Browse files
John KleinschmidtMarshallOfSound
authored andcommitted
ci: add retries to downloads for arm testing (electron#18526)
1 parent 1e3e5a6 commit a31faaa

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

script/download-circleci-artifacts.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,28 @@ async function downloadArtifact (name, buildNum, dest) {
4949
process.exit(1)
5050
} else {
5151
console.log(`Downloading ${artifactToDownload.url}.`)
52-
await downloadFile(artifactToDownload.url, dest)
53-
console.log(`Successfully downloaded ${name}.`)
52+
let downloadError = false
53+
await downloadWithRetry(artifactToDownload.url, dest).catch(err => {
54+
console.log(`Error downnloading ${artifactToDownload.url} :`, err)
55+
downloadError = true
56+
})
57+
if (!downloadError) {
58+
console.log(`Successfully downloaded ${name}.`)
59+
}
60+
}
61+
}
62+
63+
async function downloadWithRetry (url, directory) {
64+
let lastError
65+
for (let i = 0; i < 5; i++) {
66+
console.log(`Attempting to download ${url} - attempt #${(i + 1)}`)
67+
try {
68+
return await downloadFile(url, directory)
69+
} catch (err) {
70+
lastError = err
71+
}
5472
}
73+
throw lastError
5574
}
5675

5776
function downloadFile (url, directory) {

0 commit comments

Comments
 (0)
X Tutup