# Read a Retry-After header

Turn delay-seconds or an HTTP date into milliseconds to wait, never negative.

Canonical: https://1loc.dev/email/parse-a-retry-after-header/
Version: 1.0.0
Runtime: JavaScript · Node.js 22 / modern browsers
Verification: Local fixtures; no external services
Updated: 2026-10-28

## Implementation

```javascript
function retryAfterMs({ retryAfter, date }) { const seconds = Number(retryAfter); return Math.max(0, Number.isFinite(seconds) ? seconds * 1000 : Date.parse(retryAfter) - Date.parse(date)); }
```

## Input

```json
{
  "retryAfter": "30",
  "date": "Wed, 28 Oct 2026 14:00:00 GMT"
}
```

## Expected output

```json
30000
```

## Edge case

Input:
```json
{
  "retryAfter": "Wed, 28 Oct 2026 14:00:30 GMT",
  "date": "Wed, 28 Oct 2026 14:00:00 GMT"
}
```
Output:
```json
30000
```

## Limits

- An HTTP date is compared with the response’s own Date header, not your clock, so clock skew cannot shorten the wait. The lab accepts delay-seconds from 0 to 86,400.
- Oveyon answers rate limiting with HTTP 429 and Retry-After. Wait at least this long, then retry with the same idempotency key.

The lab validates types and size before calling this function. Add equivalent validation at your own trust boundary.

## Source and license

Author: Oveyon, written for this edition; not part of the original 1loc collection.
Copyright (c) 2026 Oveyon
License: MIT — https://1loc.dev/licenses/
Maintainer: Oveyon
