File tree Expand file tree Collapse file tree 1 file changed +2
-6
lines changed Expand file tree Collapse file tree 1 file changed +2
-6
lines changed Original file line number Diff line number Diff line change @@ -115,14 +115,10 @@ class SlidingWindowCounter implements RateLimiter {
115115 if ( timestamp >= window . fixedWindowStart + this . windowSize ) {
116116 // if more than one window was skipped
117117 if ( timestamp >= window . fixedWindowStart + this . windowSize * 2 ) {
118- // calculates how many windows may have been skipped since last request
119- const windowsSkipped = Math . floor (
120- ( timestamp - window . fixedWindowStart ) / this . windowSize
121- ) ;
118+ // if one or more windows was skipped, reset new window to be at current timestamp
122119 updatedUserWindow . previousTokens = 0 ;
123120 updatedUserWindow . currentTokens = 0 ;
124- updatedUserWindow . fixedWindowStart =
125- window . fixedWindowStart + this . windowSize * windowsSkipped ;
121+ updatedUserWindow . fixedWindowStart = timestamp ;
126122 } else {
127123 updatedUserWindow . previousTokens = updatedUserWindow . currentTokens ;
128124 updatedUserWindow . currentTokens = 0 ;
You can’t perform that action at this time.
0 commit comments