express-brute-redis icon indicating copy to clipboard operation
express-brute-redis copied to clipboard

Listen for redis client results and throw error on failure

Open peralmq opened this issue 8 years ago • 3 comments

When using express-brute backed by express-brute-redis as the store I ran in to problems when my redis server would become inaccessible (for some temporary network glitch or something similar).

I would have assumed that an inaccessible store would throw errors that could be handled by express-brute's handleStoreError but it turned out that some redis store errors failed silently. Instead the request to the store stalled, which then led to the bruteforce check stalling and finally the http request stalling when the redis server is inaccessible.

So, here is a fix for that. It throws more errors than the original solution, namely when the reply from the redis client is falsy (so this is different from any response coming from a successful request/response loop that actually hits the redis server.)

(I also updated the RedisMock file so that the tests are passing.)

Let me know if you need more information.

peralmq avatar Apr 19 '16 18:04 peralmq

Ping @AdamPflug any thoughts on this?

peralmq avatar Jun 01 '16 15:06 peralmq

I need this fix aswell. Thank you @peralmq for your work! @AdamPflug could you please merge this pull request?

flixcheck avatar Jun 15 '18 09:06 flixcheck

I also ran into this problem today where express-brute-redis seemed to ignore a -READONLY You can't write against a read only replica. response from the server. As far as I can tell, it then went on to try to parse OK as JSON, leading to an obscure SyntaxError: Unexpected token O in JSON at position 0 error, which ended up as an uncaught exception in my app.

Seems like someone published a fork with these changes: https://github.com/biowink/express-brute-redis

@AdamPflug, please consider merging this in.

papandreou avatar Jul 14 '19 11:07 papandreou