Nth Counting
Network and WebSocket rules can include one counting selector.
| Field | Meaning |
|---|---|
onNth | Apply only on the Nth matching request or message. |
everyNth | Apply on every Nth matching request or message. |
afterN | Apply after the first N matches have passed. |
firstN | Apply on the first N matches only, then never again. |
network: { failures: [ { urlPattern: '/api/orders', statusCode: 503, probability: 1, onNth: 3 }, ],}firstN is the rate-limit shape: fail the first attempts, then let retries through. The ai-retry-loop preset uses firstN: 2 to return 429 twice before a clean response.
network: { failures: [ { urlPattern: '/api/chat', statusCode: 429, probability: 1, firstN: 2 }, ],}Counting is per rule object and shared across fetch and XHR for the same config entry. Set at most one of onNth, everyNth, afterN, or firstN on a rule.