File tree 2 files changed +5
-2
lines changed
2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,10 @@ export class RateLimiter {
18
18
private readonly hourLimiter = new Limiter ( 12 , "hour" )
19
19
20
20
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
22
25
}
23
26
24
27
public removeToken ( ) : boolean {
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ test.describe("login", () => {
54
54
// The current RateLimiter allows 2 logins per minute plus
55
55
// 12 logins per hour for a total of 14
56
56
// See: src/node/routes/login.ts
57
- for ( let i = 1 ; i <= 13 ; i ++ ) {
57
+ for ( let i = 1 ; i <= 14 ; i ++ ) {
58
58
await page . click ( ".submit" )
59
59
await page . waitForLoadState ( "networkidle" )
60
60
// We double-check that the correct error message shows
You can’t perform that action at this time.
0 commit comments