[tests] Add retrying for GitHub actions connection error (#5533)

Follow-up to https://github.com/vercel/vercel/pull/5526 this also adds retrying for fetch connection issues in GitHub Actions to prevent false test failures.

x-ref: https://github.com/vercel/vercel/runs/1518604380
This commit is contained in:
JJ Kasper
2020-12-09 15:11:01 -06:00
committed by GitHub
parent 704424ec58
commit 6d6ccbdc25

View File

@@ -1,9 +1,9 @@
const fetch = require('node-fetch');
const retryBailByDefault = require('./retry-bail-by-default.js');
async function fetchRetry (...args) {
async function fetchRetry(...args) {
return await retryBailByDefault(
async (canRetry) => {
async canRetry => {
try {
return await fetch(...args);
} catch (error) {
@@ -14,6 +14,8 @@ async function fetchRetry (...args) {
// request to https://api-gru1.vercel.com/v3/now/deployments/dpl_FBWWhpQomjgwjJLu396snLrGZYCm failed, reason:
// connect ETIMEDOUT 18.228.143.224:443
throw canRetry(error);
} else if (error.code === 'ECONNRESET') {
throw canRetry(error);
}
throw error;
}