({
statusCode,
errorType,
retryableStatusCodes,
}: AIRouterFailure)
| 273 | const DEFAULT_RETRYABLE_STATUS_CODES = new Set([429, 500, 502, 503, 504]); |
| 274 | |
| 275 | export function isAIRouterRetryableFailure({ |
| 276 | statusCode, |
| 277 | errorType, |
| 278 | retryableStatusCodes, |
| 279 | }: AIRouterFailure): boolean { |
| 280 | if (errorType === 'network' || errorType === 'timeout') { |
| 281 | return true; |
| 282 | } |
| 283 | |
| 284 | if (typeof statusCode !== 'number') { |
| 285 | return false; |
| 286 | } |
| 287 | |
| 288 | if (DEFAULT_RETRYABLE_STATUS_CODES.has(statusCode)) { |
| 289 | return true; |
| 290 | } |
| 291 | |
| 292 | return retryableStatusCodes?.includes(statusCode) ?? false; |
| 293 | } |
| 294 | |
| 295 | interface AIRouterHandlerOptions { |
| 296 | baseUrl?: string; |
no outgoing calls
no test coverage detected