Added await so the limiter actually limits messages instead of ignoring the Promise#39
Added await so the limiter actually limits messages instead of ignoring the Promise#39clibequilibrium wants to merge 2 commits intocloudflare:masterfrom clibequilibrium:master
Conversation
|
Hey @clibequilibrium, it looks like If it's not cooling down, we set Does that make sense? Out of curiosity, did you observe messages not being rate limited properly? I don't think any of the rate limiting code has changed recently, though I would need to take a closer look. |
Hello ! Thank you for your reply. On my end I use typescript and since the function is market as async , returning false or true automatically converts it to Promise. So yes I tested it and since it was not awaiting the Promise the condition was never false, because it is always returns a Promise which is not null. On side note, awaiting the Promise increased my DO duration because DO waits for the cooldown. |
|
Ahhh, I see, it looks like I'm going to close this PR, since it seems to be a merge conflict issue between |
Ah you are totally right ! The fault is on me 😁 I see that the master does not have the function marked as async . My bad ! |
|
I went ahead and committed an update to #28 to revert checkLimit() back to being synchronous, in the hopes of avoiding confusion for anyone else who might choose to use that branch. |

This PR fixes the issue where the Rate Limiter not actually limits actually because the Promise is not awaited so the messages are still going through.