refactor(github): retry abuse detection ony once

This commit is contained in:
Rhys Arkins 2018-10-28 14:46:52 +01:00
parent 9295efecdd
commit 99014ff973

View file

@ -117,24 +117,27 @@ async function get(path, options, retries = 5) {
throw new Error('platform-failure');
}
if (
retries > 0 &&
err.statusCode === 403 &&
err.message &&
err.message.startsWith('You have triggered an abuse detection mechanism')
) {
logger.info(
{
headers: err.headers,
path,
statusCode: err.statusCode,
message: err.message,
},
`Retrying request`
);
if (retries > 0) {
logger.info(
{
headers: err.headers,
path,
statusCode: err.statusCode,
message: err.message,
},
`Retrying request`
);
await delay(180000 / (retries * retries));
await delay(180000 / (retries * retries));
return get(path, opts, retries - 1);
return get(path, opts, 0);
}
// istanbul ignore next
throw new Error('platform-failure');
}
if (
err.statusCode === 403 &&