diff --git a/index.js b/index.js index 2dc86a9659..2c2ae23c7f 100644 --- a/index.js +++ b/index.js @@ -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