( attempt: number, totalAttempts: number, decision: RetryDecision, baseDelayMs: number, )
| 270 | ) => Promise<GenerateResult>; |
| 271 | |
| 272 | function buildRetryInfo( |
| 273 | attempt: number, |
| 274 | totalAttempts: number, |
| 275 | decision: RetryDecision, |
| 276 | baseDelayMs: number, |
| 277 | ): RetryReason { |
| 278 | const backoff = computeDelay(attempt, baseDelayMs); |
| 279 | const delayMs = |
| 280 | decision.retryAfterMs !== undefined ? Math.max(decision.retryAfterMs, backoff) : backoff; |
| 281 | const info: RetryReason = { attempt, totalAttempts, delayMs, reason: decision.reason }; |
| 282 | if (decision.retryAfterMs !== undefined) info.retryAfterMs = decision.retryAfterMs; |
| 283 | return info; |
| 284 | } |
| 285 | |
| 286 | function shouldStop(decision: RetryDecision, attempt: number, maxRetries: number): boolean { |
| 287 | return !decision.retry || attempt >= maxRetries; |
no test coverage detected