Skip to content

Commit ede23d7

Browse files
authored
fix: correct calculation of refilledAt (#1779)
1 parent f4333e2 commit ede23d7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pages/rate-limit/token-bucket.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class TokenBucketRateLimit<_Key> {
3535
}
3636
const refill = Math.floor((now - bucket.refilledAt) / (this.refillIntervalSeconds * 1000));
3737
bucket.count = Math.min(bucket.count + refill, this.max);
38-
bucket.refilledAt = bucket.refilledAt + refill * this.refillIntervalSeconds;
38+
bucket.refilledAt = bucket.refilledAt + refill * this.refillIntervalSeconds * 1000;
3939
if (bucket.count < cost) {
4040
return false;
4141
}

0 commit comments

Comments
 (0)