Skip to content

fix: honor Retry-After on 429s so concurrent retries don't thunder - #422

Open
vedant7007 wants to merge 1 commit into
codepvg:mainfrom
vedant7007:fix/retry-honor-retry-after
Open

fix: honor Retry-After on 429s so concurrent retries don't thunder#422
vedant7007 wants to merge 1 commit into
codepvg:mainfrom
vedant7007:fix/retry-honor-retry-after

Conversation

@vedant7007

Copy link
Copy Markdown
Contributor

Problem

scripts/lib/retry-interceptor.js backs off by INITIAL_DELAY_MS * 2^(n-1) + up to 200ms jitter and ignores the server's Retry-After header. The sync scripts fire batches of CONCURRENCY_LIMIT = 20; on a 429 all 20 retry within a ~200ms band and re-hammer the API in lockstep (thundering herd), likely re-triggering the limit.

Fix

  • Parse Retry-After (RFC 7231 delay-seconds or HTTP-date) → ms; absent/garbage → 0.
  • Delay = max(Retry-After, exponentialBackoff) so we never retry sooner than the server asked.
  • Widen jitter to a full second to de-correlate the batch.

Test

Added a self-contained check for parseRetryAfter covering seconds, HTTP-date (future clamps forward, past clamps to 0), absent, capitalized, and unparseable headers — all pass. Syntax-checked with node --check.

Closes #380

The retry interceptor backed off by INITIAL_DELAY_MS * 2^(n-1) + up to 200ms
jitter and ignored the server's Retry-After header. Sync scripts fire batches
of 20 requests; on a 429 all 20 retried within a ~200ms band and re-hammered
the API in lockstep, re-triggering the limit.

Parse Retry-After (delay-seconds or HTTP-date), retry no sooner than
max(Retry-After, exponentialBackoff), and widen jitter to a full second to
de-correlate the batch.

Closes codepvg#380
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Thank you for submitting a pull request.

Please ensure your changes comply with the project's contribution guidelines and that all workflow checks pass successfully.

Formatting and Branching

  • Please confirm you have formatted your code locally using npx prettier --write . before requesting a review.
  • Ensure this PR is made from a feature/* branch and not main.

Note: This project is currently maintained by a solo maintainer, so reviews and responses may sometimes take a little time. Thanks for your patience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Retry interceptor ignores Retry-After — 20 concurrent 429s retry in lockstep (thundering herd)

1 participant