Skip to content
Latest stable: v0.9.0.

Nth Counting

Network and WebSocket rules can include one counting selector.

FieldMeaning
onNthApply only on the Nth matching request or message.
everyNthApply on every Nth matching request or message.
afterNApply after the first N matches have passed.
firstNApply 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.