`HttpClient.withRateLimiter`: let `RateLimiterError` be handled as an `HttpClientError`
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
Issue này chưa được đánh giá.
Mô tả
What is the problem this feature would solve?
HttpClient.withRateLimiter adds RateLimiter.RateLimiterError to the client's error type, so the result isn't a plain HttpClient any more. To provide it as HttpClient.HttpClient again, the error has to be removed:
httpClient.pipe(
HttpClient.withRateLimiter({
limiter,
key: 'orcid',
algorithm: 'token-bucket',
limit: 24,
window: '1 second',
}),
HttpClient.catchTag('RateLimiterError', Effect.die),
)
The natural thing would be to turn it into an HttpClientError with a TransportError reason, so callers handle a failing limiter store (such as Redis being unavailable) like any other failed request. But TransportError needs the request, and HttpClient.catchTag's handler only receives the error, so dying is the only option.
HttpClient.transform does receive the request, but it only changes the response side. The RateLimiterError stays in the client's preprocess type, so the result still isn't assignable to HttpClient.
We're working around it by calling RateLimiter.sleep inside HttpClient.transform ourselves. That loses withRateLimiter's 429 retries and its handling of rate-limit headers.
What is the feature you are proposing to solve the problem?
Any of these would work:
- An option on
withRateLimiterto fail with anHttpClientError(TransportError, with theRateLimiterErroras itscause) instead of aRateLimiterError, so the result is a plainHttpClient. - Pass the request to the handlers of
HttpClient.catchTag,HttpClient.catchTagsandHttpClient.catch, for example as a second argument. - Make
HttpClient.transform(or a variant of it) able to handle errors from the whole client, not just the response.
Option 1 fits best for HTTP clients. Option 2 would help with other errors added by client combinators too.
What alternatives have you considered?
HttpClient.catchTag('RateLimiterError', Effect.die): fine withRateLimiter.layerStoreMemory, which can't fail, but a store failure withlayerStoreRedisbecomes a defect.RateLimiter.sleepinsideHttpClient.transform, mapping the error with the request: works, but reimplements part ofwithRateLimiterand loses its 429 and header handling.
Version: effect 4.1.2
- Ngôn ngữ chính
- TypeScript
- Star
- 16.7k
- Fork
- 808
- Merge trung bình
- 20 giờ 31 phút
- Pull request đã merge (30 ngày)
- 733
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Effect-TS/effect
-
ai-amazon-bedrock: a tool result that isn't a JSON object fails the next requestCó thể đã có người làm @effect-bot đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
Maintainer thường phản hồi trong vòng 1 ngày
-
HttpApiEndpoint: static path and wildcard (/*) path with the same prefix are treated as duplicate routesCó thể đã có người làm @effect-bot đã nhận hôm nay. Đang mởbug
Effect-TS/effect#10765 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 10/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Investigate Deno CI timeouts in JSDoc diagnostic testsCó thể đã có người làm @haranishi đã nhận hôm nay. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của Effect-TS/effect
Issue tương tự
-
type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
db-ux-design-system/core-web#8856 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
'!' breaking change is lost when the commit also has an empty BREAKING CHANGE footerCó thể đã có người làm @wittdennis đã nhận hôm nay. Đang mởpriority: p3 type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
googleapis/release-please#2971 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 87/100
Maintainer thường phản hồi trong vòng 1 ngày
-
🛠️ dette technique
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 61/100
betagouv/mon-entreprise#4752 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 5 ngày