Add retry and response header options to HttpClient.withRateLimiter - #6827
Add retry and response header options to HttpClient.withRateLimiter#6827jaipaljadeja wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 99221ed The changes in this PR will be included in the next version bump. This PR includes changesets to release 30 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
timesoption — bounds automatic 429 retries. Defaults to undefined (unlimited), 0 disables.responseHeadersoption — per-field header name overrides for rate-limit metadata inspection. Unset fields continue using built-in names.- Retry-count logic —
canRetrygate in both success and error paths, with response inspection running before the gate so the limiter learns from terminal 429s. - Tests — custom header parsing, bounded retries (success and error channels), custom Retry-After, terminal 429 feedback with
times: 0, header override isolation. - Type-level coverage — new options accepted in both data-first and data-last positions.
DeepSeek Pro (free via Pullfrog for OSS) (Kimi K2 not used — the program covers this model; add its provider key to run your pick) | 𝕏
6b2b895 to
99221ed
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Added
timesoption — bounds automatic 429 retries after the initial request. Defaults to unlimited (undefined), and0disables retries entirely. - Added
responseHeadersoption — allows per-field override of the header names used for rate-limit inspection (limit,remaining,reset,resetAfter,retryAfter). Unconfigured fields keep the built-in names. - Retry-count logic —
canRetrygate on both the success and error paths, with response inspection running before the gate so the limiter still learns from terminal 429s. - Tests — added coverage for custom limit/reset headers, custom remaining/reset-after headers, header-override isolation (no fallback to built-ins), bounded retries on both success and error channels, custom retry-after header, and Retry-After feedback when retries are disabled.
- Type-level coverage —
timesandresponseHeadersaccepted in both data-first and data-last positions.
@v0 or keep the SHA fresh with Dependabot | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|

Type
Description
Adds two options to
HttpClient.withRateLimiter:timeslimits the number of automatic retries after a429response. It counts retries after the initial request, andtimes: 0disables automatic retries. Omitting it preserves the existing unlimited behavior.responseHeadersallows individual rate-limit response header names to be overridden. Fields that are not configured continue using the existing built-in names.When the retry limit is reached, the final
429is returned or failed through its original channel. Response inspection still runs before that happens, allowing the limiter to learn from the final response.Also updates the public API JSDoc and adds runtime and type-level coverage.
Validation:
pnpm lint-fixpnpm lintpnpm --filter effect test --run test/unstable/http/HttpClient.test.tspnpm test-types packages/effect/typetest/unstable/http/HttpClient.tst.tspnpm check