mirror of
https://code.forgejo.org/actions/checkout.git
synced 2026-07-05 02:56:14 +00:00
Handle checkout 500 retries with backoff
Switch the shared retry helper from randomized delays to exponential backoff so transient GitHub 500 errors are retried predictably. Add coverage for the backoff sequence and regenerate the bundled dist output. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
b9e0990d21
commit
fcdb15c322
3 changed files with 72 additions and 18 deletions
10
dist/index.js
vendored
10
dist/index.js
vendored
|
|
@ -35491,7 +35491,7 @@ class retry_helper_RetryHelper {
|
|||
info(err?.message);
|
||||
}
|
||||
// Sleep
|
||||
const seconds = this.getSleepAmount();
|
||||
const seconds = this.getSleepAmount(attempt);
|
||||
info(`Waiting ${seconds} seconds before trying again`);
|
||||
await this.sleep(seconds);
|
||||
attempt++;
|
||||
|
|
@ -35499,9 +35499,11 @@ class retry_helper_RetryHelper {
|
|||
// Last attempt
|
||||
return await action();
|
||||
}
|
||||
getSleepAmount() {
|
||||
return (Math.floor(Math.random() * (this.maxSeconds - this.minSeconds + 1)) +
|
||||
this.minSeconds);
|
||||
getSleepAmount(attempt) {
|
||||
if (this.minSeconds === 0) {
|
||||
return 0;
|
||||
}
|
||||
return Math.min(this.minSeconds * Math.pow(2, attempt - 1), this.maxSeconds);
|
||||
}
|
||||
async sleep(seconds) {
|
||||
return new Promise(resolve => setTimeout(resolve, seconds * 1000));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue