-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
redis client does not have an error handler #13
Comments
Thanks for reporting this, @jeffmcaffer. I think there might be three ways of approaching this:
I'm not a huge fan of either 2. or 3., but that's probably also because we actually "crash-by-design" in our app when something low-level like a connection goes down. As far as I can tell, a connection issue is going to be the most common scenario for error handling here, as each individual library call has its own error handling. If we only do 1, it should be made clear that the library doesn't handle errors of course. What do you think? |
That seems reasonable. People can also construct up their own client and pass it in (that's what we do now). I mostly opened this because I didn't foresee the crash-by-design scenario. On a slightly different front, what is the need for the passed in client to be an actual instance of redis.RedisClient? Forcing the use of that class restricts us from using ioredis or mocking up a redis client with plain old objects. Again, not a huge deal, more curious than anything. Thanks for the library. We are making good use of it in GHCrawler |
Thanks for the feedback. Would it work for you then, if we made it explicit that low-level errors (as reported by the client itself) are not being handled specifically by this library? Regarding your second note: To be honest, the ability to re-use a client was an afterthought and micro-optimization (we wanted to re-use an existing connection, basically), and we just based it on the I'm really happy to hear that this library is being used by others libraries! It's a good motivation to take a look at this lib again and perhaps update it to ES6 and Node 4+ only support, including native promises. I see you are using ES6 in your library, so I imagine an update like that would work without hiccups as well (It would still be a new major version, of course). |
For our case we create a redis client and supply that so we are not blocked/affected now. You could make it clear in the doc that folks should either, pass in their own, get the one you make and add an error handler or crash-by-design. For different redis libraries, we were considering moving to ioredis for various reasons (mostly some of the auto reconnect behavior). It was not a major issue but one of the things that stopped that move was this library's hard dependency on the specific redis lib. It did appear that they would be compatible but we also did not spend a long time on it. Thanks for engaging here. |
If the user passes in redis options (rather than an actual client instance), this code makes a new client. That's great but it needs to have an .on('error', ...) handler. Without it, any errors in the redis client will immediately crash the app. Even something as simple as the following would do the trick.
The text was updated successfully, but these errors were encountered: