* Fetch policy limits with retry logic and exponential backoff
( cachedChecksum?: string, )
| 265 | * Fetch policy limits with retry logic and exponential backoff |
| 266 | */ |
| 267 | async function fetchWithRetry( |
| 268 | cachedChecksum?: string, |
| 269 | ): Promise<PolicyLimitsFetchResult> { |
| 270 | let lastResult: PolicyLimitsFetchResult | null = null |
| 271 | |
| 272 | for (let attempt = 1; attempt <= DEFAULT_MAX_RETRIES + 1; attempt++) { |
| 273 | lastResult = await fetchPolicyLimits(cachedChecksum) |
| 274 | |
| 275 | if (lastResult.success) { |
| 276 | return lastResult |
| 277 | } |
| 278 | |
| 279 | if (lastResult.skipRetry) { |
| 280 | return lastResult |
| 281 | } |
| 282 | |
| 283 | if (attempt > DEFAULT_MAX_RETRIES) { |
| 284 | return lastResult |
| 285 | } |
| 286 | |
| 287 | const delayMs = getRetryDelay(attempt) |
| 288 | logForDebugging( |
| 289 | `Policy limits: Retry ${attempt}/${DEFAULT_MAX_RETRIES} after ${delayMs}ms`, |
| 290 | ) |
| 291 | await sleep(delayMs) |
| 292 | } |
| 293 | |
| 294 | return lastResult! |
| 295 | } |
| 296 | |
| 297 | /** |
| 298 | * Fetch policy limits (single attempt, no retries) |
no test coverage detected