fastify / fastify-rate-limit

A low overhead rate limiter for your routes
MIT License
504 stars 71 forks source link

Retry-After: return the TTL instead of timeWindow #324

Closed gurgunday closed 1 year ago

gurgunday commented 1 year ago

Retry-After, the internet standard counterpart of x-ratelimit-reset, was for some reason always being set to the timeWindow property when rate limiting took place - so for instance even when a user had to wait for 5 more seconds for rate limiting to be lifted (with a timeWindow of 15 seconds), the user would still see on the header the number 15 instead of 5

I traced back a change that, while introducing the optional draft headers feature, had done away with this but probably couldn't change the default behavior to make it non-breaking

While another breaking PR is up, I think we can also make this change