Skip to content

Commit 9df25e9

Browse files
committed
changed new window start to equal old window end
1 parent ff74d90 commit 9df25e9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/rateLimiters/slidingWindowCounter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ class SlidingWindowCounter implements RateLimiter {
112112
};
113113

114114
// if request time is in a new window
115-
if (timestamp >= window.fixedWindowStart + this.windowSize + 1) {
115+
if (timestamp >= window.fixedWindowStart + this.windowSize) {
116116
updatedUserWindow.previousTokens = updatedUserWindow.currentTokens;
117117
updatedUserWindow.currentTokens = 0;
118-
updatedUserWindow.fixedWindowStart = window.fixedWindowStart + this.windowSize + 1;
118+
updatedUserWindow.fixedWindowStart = window.fixedWindowStart + this.windowSize;
119119
}
120120

121121
// assigned to avoid TS error, this var will never be used as 0

0 commit comments

Comments
 (0)