fix: reduce rate-limit log spam when quota is healthy (#7599)

Co-authored-by: Frank Elsinga <frank@elsinga.de>
This commit is contained in:
hexonal
2026-07-24 22:33:38 +08:00
committed by GitHub
parent 37009a28f2
commit 1aa80912e7
+12 -1
View File
@@ -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({