We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3ab7e5c commit 9dc71a7Copy full SHA for 9dc71a7
library/ratelimiting/RateLimiter.ts
@@ -22,6 +22,14 @@ export class RateLimiter {
22
(timestamp) => currentTime - timestamp <= windowSizeInMS
23
);
24
25
+ // Ensure the number of entries exceeds maxRequests by only 1
26
+ if (filteredTimestamps.length > maxRequests + 1) {
27
+ filteredTimestamps.splice(
28
+ 0,
29
+ filteredTimestamps.length - (maxRequests + 1)
30
+ );
31
+ }
32
+
33
// Add current request timestamp to the list
34
filteredTimestamps.push(currentTime);
35
0 commit comments