Webhook retry docs describe behavior the code doesn't have (non-2xx, and a 100ms first delay)
Two claims in Webhook retries & debugging don't match master (942bdad):
Nango retries each webhook with non-2xx responses 2 times with exponential backoff (starting delay: 100ms, time multiple: 2 […])
I drove deliver() against a local server to check, rather than reading it:
429 rate-limited httpAttempts=1 delivered=false gaps=[]
400 bad request httpAttempts=1 delivered=false gaps=[]
500 server error httpAttempts=3 delivered=false gaps=[3005, 6004] ms1. It isn't non-2xx — a 4xx is never retried.
shouldRetry in packages/webhooks/lib/utils.ts treats 300..499 as final, so only 5xx and a fixed list of network errors are retried:
if (status >= 300 && status < 500) {
return { retry: false, reason: `status_code_${status}` };
}The case worth calling out is 429. Reading the current docs you'd expect Nango to back off and retry when your endpoint rate-limits it. It gets one attempt and stops.
(3xx lands in that branch too, but it rarely reaches it: the delivery call passes maxRedirects from the outbound policy, default 5, so a redirect is followed — 301 -> 200 delivered successfully in 2 hops in the same harness. Worth a sentence in the docs, since neither behavior is written down.)
2. The first delay is 3 seconds, not 100ms.
getExponentialBackoff in packages/utils/lib/retry.ts is Math.min(3000 * 2 ** attempt, maxDelay) — the measured gaps above are 3005 ms and 6004 ms. (The doc's link points at packages/webhooks/lib/utils.ts, which has the retry predicate; the delays live one package over.)
The 100ms looks like it predates #3662, which moved webhooks from retryWithBackoff to retryFlexible — exponential-backoff's defaults are startingDelay: 100, timeMultiple: 2, which is exactly what the sentence still describes.
Suggested replacement
Nango retries a failed webhook 2 times, with exponential backoff: it waits 3 seconds before the first retry and 6 seconds before the second.
A delivery is retried when it fails with a 5xx response, or with a network error (
ECONNRESET,ETIMEDOUT,ECONNABORTED,ECONNREFUSED,EHOSTUNREACH,EAI_AGAIN,UND_ERR_SOCKET). A 4xx response is treated as final and is not retried. Redirects are followed, up to 5 hops.Note —
429is a 4xx, so Nango does not wait and retry when your endpoint rate-limits it; the delivery gets one attempt. If your webhook handler is rate-limited, accept the request and queue the work on your side rather than returning429.
One thing I can't tell from outside: whether not retrying 429 is intended. If the intent was to back off on a rate-limited endpoint, this is a code fix rather than a docs fix and I'd rather say so than assume.
Happy to open a PR instead, though I read CONTRIBUTING.md as preferring an issue here.
Source: NangoHQ/nango