1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-04 15:02:09 +03:00

Fixed an unexpected exception bug when reconnecting in pub/sub mode if selected_db is not null

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.
This commit is contained in:
roam
2012-12-19 15:04:07 +08:00
parent c3ea30ebea
commit 11db346e73

View File

@@ -282,7 +282,12 @@ RedisClient.prototype.on_ready = function () {
// magically restore any modal commands from a previous connection
if (this.selected_db !== null) {
// this trick works if and only if the following send_command
// never goes into the offline queue
var pub_sub_mode = this.pub_sub_mode;
this.pub_sub_mode = false;
this.send_command('select', [this.selected_db]);
this.pub_sub_mode = pub_sub_mode;
}
if (this.pub_sub_mode === true) {
// only emit "ready" when all subscriptions were made again