mirror of
https://github.com/actions/toolkit.git
synced 2026-08-19 00:00:17 +02:00
only retry downloadtool on 500s and 408 and 429 (#373)
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user