upstash / ratelimit-js

Rate limiting library for serverless runtimes
https://ratelimit-with-vercel-kv.vercel.app
MIT License
1.66k stars 33 forks source link

Fix fixed window algorithm #62

Closed mdumandag closed 1 year ago

mdumandag commented 1 year ago

The value of usedTokensAfterUpdate can be greater than the max number of tokens. To not return a negative remaining value we should take max of it with 0 before returning it.

vercel[bot] commented 1 year ago

@mdumandag is attempting to deploy a commit to the Upstash Team on Vercel.

A member of the Team first needs to authorize it.