express-brute-redis
express-brute-redis copied to clipboard
Listen for redis client results and throw error on failure
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.
Ping @AdamPflug any thoughts on this?
I need this fix aswell. Thank you @peralmq for your work! @AdamPflug could you please merge this pull request?
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.