File tree Expand file tree Collapse file tree 2 files changed +5
-2
lines changed
Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,10 @@ export class RateLimiter {
1818 private readonly hourLimiter = new Limiter ( 12 , "hour" )
1919
2020 public canTry ( ) : boolean {
21- return this . minuteLimiter . getTokensRemaining ( ) > 0 || this . hourLimiter . getTokensRemaining ( ) > 0
21+ // Note: we must check using >= 1 because technically when there are no tokens left
22+ // you get back a number like 0.00013333333333333334
23+ // which would cause fail if the logic were > 0
24+ return this . minuteLimiter . getTokensRemaining ( ) >= 1 || this . hourLimiter . getTokensRemaining ( ) >= 1
2225 }
2326
2427 public removeToken ( ) : boolean {
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ test.describe("login", () => {
5454 // The current RateLimiter allows 2 logins per minute plus
5555 // 12 logins per hour for a total of 14
5656 // See: src/node/routes/login.ts
57- for ( let i = 1 ; i <= 13 ; i ++ ) {
57+ for ( let i = 1 ; i <= 14 ; i ++ ) {
5858 await page . click ( ".submit" )
5959 await page . waitForLoadState ( "networkidle" )
6060 // We double-check that the correct error message shows
You can’t perform that action at this time.
0 commit comments