mirror of
https://github.com/actions/checkout.git
synced 2026-07-19 04:30:04 +08:00
Merge fcdb15c322 into 3d3c42e5aa
This commit is contained in:
commit
1bcc353802
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