Skip to content

What happens if memcached in unavailable? #8

Answered by nfriedly
ngdaddikar asked this question in Q&A
Discussion options

You must be logged in to vote

You could write your own wrapper, something like this:

const limiter = rateLimit({ /* ... */ });
app.use((req, res, next) => {
  limiter(req, res, (err) => {
    if (err) {
      console.error('error from express-rate-limit, allowing request', err);
    }
    next();
  }
});

That will log the error and then continue handling the request as if the limiter was allowed. It's not a great idea, because if a malicious user figured out a way to reliably trigger errors, they'd be able to bypass your limiter. (Also, this example ignores all errors, not just store-related ones.) But, it would allow you to prioritize availability over rate-limiting.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@nfriedly
Comment options

Answer selected by ngdaddikar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants