[CI] Fix axios requests to allow retry (#182386)

## Summary
Related to #181733 - I didn't check, and axios rejects requests'
promises that don't result in `2xx`.

This PR wraps the attempt in a try-catch to be able to retry.
This commit is contained in:
Alex Szabo 2024-05-03 08:58:36 +02:00 committed by GitHub
parent af580c9f92
commit 389025e814
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -46,14 +46,22 @@ async function main() {
async function headAssetUrl(assetPath: string) {
const testUrl = `${CDN_URL_PREFIX}/${assetPath}`;
const response = await axios.head(testUrl, {
timeout: 1000,
});
return {
status: response.status,
testUrl,
assetPath,
};
try {
const response = await axios.head(testUrl, {
timeout: 1000,
});
return {
status: response.status,
testUrl,
assetPath,
};
} catch (error) {
return {
status: error.response?.status || 0,
testUrl,
assetPath,
};
}
}
async function headAssetUrlWithRetry(