When unsubscribe or punsubscribe is called and it has
no subscriptions, the reply[1] is a null which causes
`TypeError: Cannot call method 'toString' of null`
Check if reply[1] is null before calling toString otherwise
just pass null.
When unsubscribe or punsubscribe is called
and there is nothing to unsubscribe from, the reply[1]
argument is a null which causes a TypeError
Cannot call method 'toString' of null
```
TypeError: Cannot call method 'toString' of null
at RedisClient.return_reply (/Users/barczewskij/projects/node_redis/index.js:633:65)
at ReplyParser.RedisClient.init_parser (/Users/barczewskij/projects/node_redis/index.js:266:14)
at ReplyParser.EventEmitter.emit (events.js:96:17)
at ReplyParser.send_reply (/Users/barczewskij/projects/node_redis/lib/parser/javascript.js:300:10)
at ReplyParser.execute (/Users/barczewskij/projects/node_redis/lib/parser/javascript.js:211:22)
at RedisClient.on_data (/Users/barczewskij/projects/node_redis/index.js:483:27)
at Socket.<anonymous> (/Users/barczewskij/projects/node_redis/index.js:82:14)
at Socket.EventEmitter.emit (events.js:96:17)
at TCP.onread (net.js:396:14)
```
Reverting because this was a documentation problem, not a problem with
the code. Performance-wise, this is faster than the approach in #345, though
it may cause users more trouble. This is okay, if someone opens an issue we
can point them to the docs.
This reverts commit b60e001fa0.
Conflicts:
index.js
test.js
This fixes an issue where the command queue gets popped prematurely by pubsub
messages, leading to callbacks for those commands not being invoked.
Close#360.
Signed-off-by: DTrejo <david.daniel.trejo@gmail.com>
RedisClient might enter pub/sub mode after at least one SELECT command issued.
When reconnecting, the SELECT command is issued after restoring pub_sub_command to true, which causes an exception.
An uncaught exception will be raised when the retry timer tries to
reconnect and encounter an error, for all event listeners of the stream
were removed in line 826. It should set closing varable to be true.