Skip to content

Commit 9ecbecd

Browse files
committed
fix(github-stats-action): avoid shadowing delay in retry backoff
1 parent ef29364 commit 9ecbecd

File tree

1 file changed

+3
-3
lines changed
  • apps/shared-backend/github-actions/github-stats-action

1 file changed

+3
-3
lines changed

apps/shared-backend/github-actions/github-stats-action/getStats.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ async function makeRequest(url, options = {}) {
148148
// Retry helper for GitHub API calls (handles transient network errors like "Premature close")
149149
async function retryWithBackoff(fn, maxRetries = 5, initialDelayMs = 1000) {
150150
let attempt = 0
151-
let delay = initialDelayMs
151+
let backoffMs = initialDelayMs
152152
const maxDelayMs = 30000
153153
// eslint-disable-next-line no-constant-condition
154154
while (true) {
@@ -183,10 +183,10 @@ async function retryWithBackoff(fn, maxRetries = 5, initialDelayMs = 1000) {
183183
await delay(RATE_LIMIT_CONFIG.github.delayAfterRateLimit)
184184
} else {
185185
console.warn(`Retrying after error ${status || code || message} (attempt ${attempt}/${maxRetries})...`)
186-
await delay(delay + jitter)
186+
await delay(backoffMs + jitter)
187187
}
188188

189-
delay = Math.min(delay * 2, maxDelayMs)
189+
backoffMs = Math.min(backoffMs * 2, maxDelayMs)
190190
continue
191191
}
192192
throw error

0 commit comments

Comments
 (0)