Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix: fail open on rate limit errors (#3721)

Steffen Schmitzd26a54fc02e8
diff --git a/web/src/pages/api/public/ingestion.ts b/web/src/pages/api/public/ingestion.ts
index 9d243e7870..5fa74c9d12 100644
--- a/web/src/pages/api/public/ingestion.ts
+++ b/web/src/pages/api/public/ingestion.ts
@@ -118,13 +118,19 @@ export default async function handler(
throw new UnauthorizedError(authCheck.error);
}
- const rateLimitCheck = await new RateLimitService(redis).rateLimitRequest(
- authCheck.scope,
- "ingestion",
- );
-
- if (rateLimitCheck?.isRateLimited()) {
- return rateLimitCheck.sendRestResponseIfLimited(res);
+ try {
+ const rateLimitCheck = await new RateLimitService(redis).rateLimitRequest(
+ authCheck.scope,
+ "ingestion",
+ );
+
+ if (rateLimitCheck?.isRateLimited()) {
+ return rateLimitCheck.sendRestResponseIfLimited(res);
+ }
+ } catch (e) {
+ // If rate-limiter returns an error, we log it and continue processing.
+ // This allows us to fail open instead of reject requests.
+ logger.error("Error while rate limiting", e);
}
const batchType = z.object({