diff --git a/packages/utils/src/bucket.ts b/packages/utils/src/bucket.ts index d633c5378..c23a61e75 100644 --- a/packages/utils/src/bucket.ts +++ b/packages/utils/src/bucket.ts @@ -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)