* Returns the number of milliseconds to wait before the next retry attempt. * When the response carries a `Retry-After` header (sent by servers on 429 Too Many Requests * and 503 Service Unavailable), its value (in seconds) is used as the delay, capped at * `maxMs` to avoid waiting longer than th
(response: Response, defaultMs: number, maxMs: number)
| 285 | * For all other transient errors the default pause is returned. |
| 286 | */ |
| 287 | function getRetryDelayMs(response: Response, defaultMs: number, maxMs: number): number { |
| 288 | const retryAfter = response.headers.get("retry-after"); |
| 289 | if (retryAfter) { |
| 290 | const seconds = parseInt(retryAfter, 10); |
| 291 | if (!isNaN(seconds)) { |
| 292 | return Math.min(seconds * 1000, maxMs); |
| 293 | } |
| 294 | } |
| 295 | return defaultMs; |
| 296 | } |
| 297 | |
| 298 | /** |
| 299 | * Returns true of the given HTTP status code represents a transient error. |
no outgoing calls
no test coverage detected
searching dependent graphs…