fastify / fastify-rate-limit

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

Don't set the reply code automatically #284

Closed gurgunday closed 1 year ago

gurgunday commented 1 year ago

Prerequisites

🚀 Feature Proposal

A proposal to modify the behavior of rate limit errors.

Since v4, fastify-sensible no longer has the error handler that sets the reply code automatically; fastify-multipart doesn't set it either when the Content Too Large error is thrown for instance — they only set the error.statusCode, throw, and let the dev decide what to do with that information.

Currently, rate-limit sets the reply code as well as the error code and it breaks things like reply.redirect("/") calls in the error handler that don't specify a redirect code.

It's not a huge issue, but a minor inconsistency between plugins IMO.

What do you think?

Motivation

No response

Example

No response

mcollina commented 1 year ago

Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.

gurgunday commented 1 year ago

Yep I can take a look! Wouldn't this be a breaking change, though?