`HttpClient.withRateLimiter`: let `RateLimiterError` be handled as an `HttpClientError`
メンテナーはふだん 1 日以内に返信
評価
この issue はまだ評価されていません。
説明
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
- 主要言語
- TypeScript
- スター
- 16.7k
- フォーク
- 808
- 平均マージ
- 20時間 31分
- マージ済み PR(30日)
- 733
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Effect-TS/effect のほかの issue
-
ai-amazon-bedrock: a tool result that isn't a JSON object fails the next request対応中かも @effect-bot が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
メンテナーはふだん 1 日以内に返信
-
HttpApiEndpoint: static path and wildcard (/*) path with the same prefix are treated as duplicate routes対応中かも @effect-bot が今日担当しました。 オープンbug
Effect-TS/effect#10765 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 10/100
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
-
Investigate Deno CI timeouts in JSDoc diagnostic tests対応中かも @haranishi が今日担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
Effect-TS/effect の issue をすべて見る
似ている issue
-
type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
db-ux-design-system/core-web#8856 ·
メンテナーはふだん 1 日以内に返信
-
'!' breaking change is lost when the commit also has an empty BREAKING CHANGE footer対応中かも @wittdennis が今日担当しました。 オープンpriority: p3 type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
googleapis/release-please#2971 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 87/100
メンテナーはふだん 1 日以内に返信
-
🛠️ dette technique
難易度 2/5 1〜3時間 初心者へのやさしさ 61/100
betagouv/mon-entreprise#4752 · コメント 1 件 ·
メンテナーはふだん 5 日以内に返信