`HttpClient.withRateLimiter`: let `RateLimiterError` be handled as an `HttpClientError`
Los mantenedores suelen responder en 1 día
Evaluación
Este issue todavía no se ha evaluado.
Descripción
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
- Lenguaje dominante
- TypeScript
- Estrellas
- 16.7k
- Forks
- 808
- Merge medio
- 20 h 31 min
- PR fusionados (30 d)
- 733
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de Effect-TS/effect
-
ai-amazon-bedrock: a tool result that isn't a JSON object fails the next requestPosiblemente ocupada @effect-bot la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
Los mantenedores suelen responder en 1 día
-
HttpApiEndpoint: static path and wildcard (/*) path with the same prefix are treated as duplicate routesPosiblemente ocupada @effect-bot la tomó hoy. Abiertobug
Effect-TS/effect#10765 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 10/100
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
-
Investigate Deno CI timeouts in JSDoc diagnostic testsPosiblemente ocupada @haranishi la tomó hoy. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
Todos los issues de Effect-TS/effect
Issues similares
-
type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
db-ux-design-system/core-web#8856 ·
Los mantenedores suelen responder en 1 día
-
'!' breaking change is lost when the commit also has an empty BREAKING CHANGE footerPosiblemente ocupada @wittdennis la tomó hoy. Abiertopriority: p3 type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
googleapis/release-please#2971 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 87/100
Los mantenedores suelen responder en 1 día
-
🛠️ dette technique
Dificultad 2/5 1-3 horas Aptitud para principiantes 61/100
betagouv/mon-entreprise#4752 · 1 comentario ·
Los mantenedores suelen responder en 5 días