Your Retry Logic Has Never Actually Seen a 429

This blog's Retry-After post covers what a server is telling you when it returns a 429. This one is about the other side: does your client's retry logic actually do what you think it does when a 429 shows up for real — not in a unit test, but through your actual HTTP client, actual middleware, actual code path?
What "actually seen a 429" excludes
A unit test that calls your shouldRetry(response, attempt) function directly and asserts it returns true with attempt + 1 after a 429 proves that one function is written correctly. It proves essentially nothing about whether your real request pipeline — the HTTP client, any interceptor or middleware wrapping it, whatever retry library you're using — actually invokes that function at the right moment, actually waits the interval it computed, and actually resends the same request rather than a subtly different one. A client library silently dropping the request body on retry is a real, recurring bug class, and it never shows up in a test of the backoff math alone.
Deterministic is the whole point
Testing this against a real third-party API means either waiting to naturally hit their rate limit — slow, and you don't control the timing — or hammering it on purpose, which some providers will flag your account for. Neither gives you a known moment when the 429 fires, which matters because the interesting question isn't "did a 429 eventually happen," it's "did my client wait the correct amount of time between the 3rd and 4th request, specifically."
MockBase's rate limit simulation is deterministic on purpose: set the limit to 3 requests and the 4th one in the window gets a 429, every single run, not a random one. That determinism is what makes "does my backoff logic wait the right amount of time before the 4th attempt" a question you can answer with a stopwatch, in a test that behaves the same way twice in a row.
The failure modes worth actually checking
A few things only show up when you watch the real request pipeline handle a real 429, not when you unit-test the backoff math alone:
- Retrying with a different request than the original. A client that regenerates an idempotency key, drops a header, or re-serializes a body slightly differently on retry isn't really retrying the same operation anymore.
- Backing off from the wrong clock. Code that computes backoff from "when the first request was sent" instead of "when this response arrived" drifts further wrong with every added attempt.
- Giving up silently. A retry budget that's exhausted without surfacing an error to the caller looks, from the outside, identical to a request that's still pending.
None of these show up in a mocked-out unit test of the backoff function in isolation. They only show up when a real 429 travels through the real code path meant to handle it — which is the entire reason to trigger one on purpose rather than trust that the unit test already covers it.
Xerat02
Building MockBase.
More from the blog

Idempotency Keys: How to Make "Retry This" Actually Safe
A client that doesn't know whether its request succeeded has one safe option: retry with a key that lets the server recognize "I've already done this." Here's how that actually has to work.

The Retry-After Header Nobody Reads
A server hitting you with a 429 is often doing you a favor by telling you exactly how long to wait. Most clients ignore it and retry immediately anyway, making the problem worse for everyone.