From 1aa80912e73c17d525d232073c4c8d757f8e38ab Mon Sep 17 00:00:00 2001 From: hexonal Date: Fri, 24 Jul 2026 22:33:38 +0800 Subject: [PATCH] fix: reduce rate-limit log spam when quota is healthy (#7599) Co-authored-by: Frank Elsinga --- server/rate-limiter.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/server/rate-limiter.js b/server/rate-limiter.js index 8099fe736..81ae3ce0c 100644 --- a/server/rate-limiter.js +++ b/server/rate-limiter.js @@ -7,6 +7,7 @@ class KumaRateLimiter { */ constructor(config) { this.errorMessage = config.errorMessage; + this.tokensPerInterval = config.tokensPerInterval; this.rateLimiter = new RateLimiter(config); } @@ -24,7 +25,17 @@ class KumaRateLimiter { */ async pass(callback, num = 1) { const remainingRequests = await this.removeTokens(num); - log.info("rate-limit", "remaining requests: " + remainingRequests); + if (remainingRequests < this.tokensPerInterval * 0.2) { + log.warn( + "rate-limit", + `${remainingRequests}/${this.tokensPerInterval} remaining requests until rate limiting` + ); + } else { + log.debug( + "rate-limit", + `${remainingRequests}/${this.tokensPerInterval} remaining requests until rate limiting` + ); + } if (remainingRequests < 0) { if (callback) { callback({