Bug(utils) Fix bucket refill after the first time (#3097)

* bug(bucket) Fix LeakyBucket refill

* Fix formating
This commit is contained in:
Fleny
2023-08-08 18:37:41 +02:00
committed by GitHub
parent 0aeadbb275
commit 6bcb529f9a

View File

@@ -35,9 +35,11 @@ export class LeakyBucket implements LeakyBucketOptions {
this.used = this.refillAmount > this.used ? 0 : this.used - this.refillAmount
// Reset the refillsAt timestamp since it just got refilled
this.refillsAt = undefined
// Reset the timeoutId
clearTimeout(this.timeoutId)
this.timeoutId = undefined;
if (this.used > 0) {
if (this.timeoutId) clearTimeout(this.timeoutId)
this.timeoutId = setTimeout(() => {
this.refillBucket()
}, this.refillInterval)