only retry downloadtool on 500s and 408 and 429 (#373)

This commit is contained in:
eric sciple
2020-03-09 14:35:53 -04:00
committed by GitHub
parent 82fbe5da0f
commit 5859d7172e
6 changed files with 136 additions and 38 deletions

View File

@@ -21,13 +21,20 @@ export class RetryHelper {
}
}
async execute<T>(action: () => Promise<T>): Promise<T> {
async execute<T>(
action: () => Promise<T>,
isRetryable?: (e: Error) => boolean
): Promise<T> {
let attempt = 1
while (attempt < this.maxAttempts) {
// Try
try {
return await action()
} catch (err) {
if (isRetryable && !isRetryable(err)) {
throw err
}
core.info(err.message)
}