`HttpClient.withRateLimiter`: let `RateLimiterError` be handled as an `HttpClientError`
I maintainer di solito rispondono entro 1 giorno
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
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
- Lingua principale
- TypeScript
- Stelle
- 16.7k
- Fork
- 808
- Merge medio
- 20h 31m
- PR unite (30g)
- 733
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Effect-TS/effect
-
ai-amazon-bedrock: a tool result that isn't a JSON object fails the next requestForse già presa @effect-bot l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
I maintainer di solito rispondono entro 1 giorno
-
HttpApiEndpoint: static path and wildcard (/*) path with the same prefix are treated as duplicate routesForse già presa @effect-bot l’ha presa oggi. Apertabug
Effect-TS/effect#10765 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 10/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
-
Investigate Deno CI timeouts in JSDoc diagnostic testsForse già presa @haranishi l’ha presa oggi. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di Effect-TS/effect
Issue simili
-
type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
db-ux-design-system/core-web#8856 ·
I maintainer di solito rispondono entro 1 giorno
-
'!' breaking change is lost when the commit also has an empty BREAKING CHANGE footerForse già presa @wittdennis l’ha presa oggi. Apertapriority: p3 type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
googleapis/release-please#2971 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 87/100
I maintainer di solito rispondono entro 1 giorno
-
🛠️ dette technique
Difficoltà 2/5 1-3 ore Idoneità per principianti 61/100
betagouv/mon-entreprise#4752 · 1 commento ·
I maintainer di solito rispondono entro 5 giorni