A fixed retry interval makes many clients return together after a rate limit. Combine randomized delay, a finite attempt budget and the server’s requested retry time.
Build the example
Treat successful queued responses as ordinary polling and transient 429 or 503 responses as retry candidates. Read Retry-After as either a number of seconds or an HTTP date. For invalid or past dates, use the local delay. Calculate an exponential ceiling with a cap, pick a random delay inside it, then respect a valid server-provided minimum. If that delay would exceed the job deadline, end the attempt and show a resumable state.
In a simple clock fixture, put the first request at time zero, the second after the required delay and a terminal response after the third. Capture scheduled waits, not just requests that reached the server. The distinction exposes loops that schedule a replacement timer after an abort even when no further request happens.
delayMs = Math.max(serverMinimumMs, rng() * Math.min(8000, 500 * 2 ** attempt))Watch the failure boundary
Keep the exponential state local to one job so a throttled export does not slow an unrelated screen. Record the delay and the failure class in development logs, with no request credentials. Treat permission errors and missing jobs as actionable outcomes. Retry handling should live in one layer so a query library and a network wrapper do not multiply attempts.
Verify the behavior
Stub three responses with an injected clock and random source. For attempt 2 with a 500 ms base, a random value of 0.5 and Retry-After of 5 seconds, expect 5 seconds. Abort during the wait and confirm no request fires. Check both attempts and elapsed wall time so a slow server cannot keep the loop alive indefinitely.
Sources
Technical references checked .



