fastify / fastify-rate-limit

A low overhead rate limiter for your routes
MIT License
477 stars 66 forks source link

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

Closed gurgunday closed 10 months ago

gurgunday commented 10 months 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