Skip to content

A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search

chore: add a throttled log line when we're failing open in redis ratelimiter

Mohamed Bassem97cddefbcc4c
diff --git a/packages/plugins/ratelimit-redis/src/index.ts b/packages/plugins/ratelimit-redis/src/index.ts
index d7b3aa08..085348b1 100644
--- a/packages/plugins/ratelimit-redis/src/index.ts
+++ b/packages/plugins/ratelimit-redis/src/index.ts
@@ -6,10 +6,13 @@ import type {
RateLimitConfig,
RateLimitResult,
} from "@karakeep/shared/ratelimiting";
+import { throttledLogger } from "@karakeep/shared/logger";
import { PluginProvider } from "@karakeep/shared/plugins";
const KEY_PREFIX = "ratelimit:v1";
+const failOpenLog = throttledLogger(30_000);
+
export class RedisRateLimiter implements RateLimitClient {
private redis: RedisClientType;
@@ -92,7 +95,10 @@ export class RedisRateLimiter implements RateLimitClient {
}
} catch (error) {
// On Redis error, fail open (allow the request)
- console.error("Redis rate limit error:", error);
+ failOpenLog(
+ "warn",
+ `Rate limiter failed open due to Redis error: ${error}`,
+ );
return { allowed: true };
}
}