Repository navigation
feat(javascript): wait and retry on 429 with Retry-After - #6965
Merged
Merged
Conversation
Honor Retry-After as a positive whole number of seconds (otherwise 1s), keep the host up, and cap retries with maxRateLimitRetries (default 3).
Shared mock on 6697/6698, createClient plumbing for maxRateLimitRetries, and JS-only CTS covering Retry-After, missing header, exhausted retries, fail-fast, and HTML 429 with retries disabled.
Register rateLimit.test.ts on the node project and attach the exhausted retry rejection handler before fake timers fire.
Prove fake-timer waits before the second request, retry requestStream on 429 with Retry-After, generate JS-only CTS via onlyLanguages, and point the retry-strategy docs at the JavaScript transporter.
Contributor
π₯ Breaking changes detected !!Either this PR or a previous PR not released yet introduced breaking changes, be careful when merging. No code generatedIf you believe code should've been generated, please, report the issue. π Benchmark resultsBenchmarks performed on the method using a mock server, the results might not reflect the real-world performance.
|
Summary by Aikido
π New Features
β‘ Enhancements
π§ Refactors
|
MarioAlexandruDan
marked this pull request as draft
September 1, 2026 13:38
The algoliasearch common client snapshot compared the full transporter object and failed in CI after 429 retries started exposing the default.
Shared transporter 429 wait/retry grew gzip UMD sizes enough to fail bundlewatch. Raise maxSize for the affected packages.
|
π Deployed on https://6a9829001c700fd8210e0d61--api-clients-automation.netlify.app |
Log wait duration and retries left on the same-host 429 path, record triesLeft after re-queuing the host, and retry requestStream only around sendStream so mid-stream errors cannot replay events.
MarioAlexandruDan
marked this pull request as ready for review
September 2, 2026 10:39
A misbehaving intermediary answering 429 with a huge Retry-After could park requests in setTimeout for hours; cap the honored wait at 60s so other languages copy a bounded reference implementation.
β¦ wait The retry-after mock used to reply Retry-After: 1, the same 1s a client that ignores the header entirely would wait; reply with 2s and assert the delay per route so sibling-language ports must actually parse the header. Also drop the dead javascript entry from the now-skipped HTML error test.
β¦not in the run Only the mock-was-hit floor stays gated on JavaScript; any language that hit the mock gets its call counts and delays asserted, so sibling ports cannot silently skip validation.
The send and sendStream paths built the same header record inline; use a single toResponseHeaders helper, mirroring the node-http requester.
Reverts 3b32dbf. The API-545 spec explicitly rules out a client max wait: the server sends the full rate-limit window, and truncating a longer Retry-After would retry inside the same window, collect another 429, and burn the remaining budget. Waits are honored in full again and the reference doc no longer advertises a cap to the upcoming ports.
algolia-api-clients-automation-bot Bot
added a commit
to algolia/algoliasearch-client-javascript
that referenced
this pull request
Sep 3, 2026
algolia/api-clients-automation#6965 Co-authored-by: Mario-Alexandru Dan <marioalexandrudan@gmail.com>
This was referenced Sep 3, 2026
This was referenced Sep 4, 2026
This was referenced Sep 14, 2026
This was referenced Sep 15, 2026
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.
π§ What and Why
π JIRA Ticket: API-545
HTTP 429 is not a host-failover case. JavaScript now waits on the same host and retries:
Retry-Afteras a positive whole number of seconds, waited in full per the spec (no client-side max wait), otherwise 1s;maxRateLimitRetriesdefaults to 3 (0fails on the first 429). 5xx / timeout / network retries are unchanged. Other languages skip the new CTS until sibling tickets.Changes included:
client-common) intercepts 429 before the 4xx-not-retryable path, waits withsetTimeout, and re-queues the same hostrequestStreamwaits and retries on 429 usingStreamRequestError(Retry-After from node-http and fetch requesters)createClientplumbing formaxRateLimitRetries; the retry-after route replies with a 2s wait so the CTS can tell header parsing apart from the 1s fallbackonlyLanguages: ["javascript"](not a denylist of current languages)maxRateLimitRetriesand a retry-strategy note pointing at the JavaScript transporterDeferred: docs-new customize page (other repo), live e2e (no staging rate limit)
π§ͺ Test
yarn testinclients/algoliasearch-client-javascript/packages/client-commonβ 20 files, 152 testsCI=1 yarn cli cts generate javascriptCI=1 yarn cli cts run javascript --no-e2eβ 27 files, 1123 tests