fix: honor Retry-After on 429s so concurrent retries don't thunder - #422
Open
vedant7007 wants to merge 1 commit into
Open
fix: honor Retry-After on 429s so concurrent retries don't thunder#422vedant7007 wants to merge 1 commit into
vedant7007 wants to merge 1 commit into
Conversation
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
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
|
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
scripts/lib/retry-interceptor.jsbacks off byINITIAL_DELAY_MS * 2^(n-1)+ up to 200ms jitter and ignores the server'sRetry-Afterheader. The sync scripts fire batches ofCONCURRENCY_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
Retry-After(RFC 7231 delay-seconds or HTTP-date) → ms; absent/garbage →0.max(Retry-After, exponentialBackoff)so we never retry sooner than the server asked.Test
Added a self-contained check for
parseRetryAftercovering seconds, HTTP-date (future clamps forward, past clamps to 0), absent, capitalized, and unparseable headers — all pass. Syntax-checked withnode --check.Closes #380