Skip to content

Commit

Permalink
improvent: tweak retries logic when requesting the data from the API
Browse files Browse the repository at this point in the history
  • Loading branch information
thaaddeus committed Nov 5, 2021
1 parent 30f0d91 commit aa6878f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/handy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,9 @@ export async function download({
try {
return await _downloadFile(httpRequestOptions, url, downloadPath)
} catch (error) {
const badOrUnauthorizedRequest = error instanceof HttpError && (error.status === 400 || error.status === 401)
const badOrUnauthorizedRequest =
error instanceof HttpError &&
((error.status === 400 && error.message.includes('ISO 8601 format') === false) || error.status === 401)
const tooManyRequests = error instanceof HttpError && error.status === 429
// do not retry when we've got bad or unauthorized request or enough attempts
if (badOrUnauthorizedRequest || attempts === MAX_ATTEMPTS) {
Expand Down

0 comments on commit aa6878f

Please sign in to comment.