mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2026-04-15 19:48:04 +08: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