chriso / redback

A high-level Redis library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

InstanceOf comparison for redis client always fails

twalling opened this issue · comments

We create our own redis client so that we can select the DB we'd like to use as well as authorize against it. From some initial investigation it looks like the following check when creating a new redback instance is flawed based on the way Node performs instanceof comparisons.

this.client = arguments[0] instanceof redis.RedisClient

We've found that this only evaluates to true if you create a redis client using the same redis npm module that redback uses. If you create an instance using the npm module installed for the project, then you always get false. I can create a more thorough example if needed.

Here's my fix in a fork. I'm happy to submit this as a pull request or make whatever changes you think are appropriate. I tried to keep it simple and just updated it so that the constructor wasn't so overloaded. I'll update the jsdoc info as well.

https://github.com/csv/redback/commit/9df08bbe792e37eb28701a470b7dd12026168f5f