Fix throttler not triggering when maxCount > 1
This commit is contained in:
parent
97b2d3b94c
commit
95632f5880
@ -62,7 +62,7 @@ class Throttle {
|
||||
let timeDiff = currentDate - trigger.lastTrigger;
|
||||
if (timeDiff > this.holdPeriod) {
|
||||
timeDiff -= this.holdPeriod;
|
||||
trigger.count = Math.floor(Math.min(trigger.count, this.max * (1 - timeDiff / this.resetPeriod)));
|
||||
trigger.count = Math.floor(Math.min(trigger.count, (this.max + 1) * (1 - timeDiff / this.resetPeriod)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ class Throttle {
|
||||
}
|
||||
}
|
||||
|
||||
private throw(unjailedIn: number) {
|
||||
protected throw(unjailedIn: number) {
|
||||
throw new TooManyRequestsHttpError(unjailedIn);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user