(headerValue: string | null)
| 693 | } |
| 694 | |
| 695 | export function parseRetryAfter(headerValue: string | null): number | undefined { |
| 696 | if (!headerValue) return undefined; |
| 697 | const numeric = Number(headerValue); |
| 698 | if (Number.isFinite(numeric) && numeric >= 0) return Math.ceil(numeric); |
| 699 | const date = Date.parse(headerValue); |
| 700 | if (!Number.isNaN(date)) { |
| 701 | const diffMs = date - Date.now(); |
| 702 | return diffMs > 0 ? Math.ceil(diffMs / 1000) : 0; |
| 703 | } |
| 704 | return undefined; |
| 705 | } |
| 706 | |
| 707 | /** |
| 708 | * HTTP statuses that arrive without our error envelope on transient |
no outgoing calls
no test coverage detected