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

Issue #512 send_command("monitoring") is doomed to fail

This commit is contained in:
Daniel Price
2015-08-21 14:57:48 -07:00
parent 323d6a2fda
commit 575ade907c
2 changed files with 23 additions and 1 deletions

View File

@@ -369,7 +369,7 @@ RedisClient.prototype.on_ready = function () {
}); });
return; return;
} else if (this.monitoring) { } else if (this.monitoring) {
this.send_command("monitor"); this.send_command("monitor", []);
} else { } else {
this.send_offline_queue(); this.send_offline_queue();
} }

View File

@@ -84,6 +84,28 @@ describe("The node_redis client", function () {
}); });
}); });
it("reconnects properly when monitoring", function (done) {
client.on("reconnecting", function on_recon(params) {
client.on("ready", function on_ready() {
assert.strictEqual(client.monitoring, true, "monitoring after reconnect");
client.removeListener("ready", on_ready);
client.removeListener("reconnecting", on_recon);
done();
});
});
assert.strictEqual(client.monitoring, false, "monitoring off at start");
client.set("recon 1", "one");
client.monitor(function (err, res) {
assert.strictEqual(client.monitoring, true, "monitoring on after monitor()");
client.set("recon 2", "two", function (err, res) {
// Do not do this in normal programs. This is to simulate the server closing on us.
// For orderly shutdown in normal programs, do client.quit()
client.stream.destroy();
});
});
});
// TODO: we should only have a single subscription in this this // TODO: we should only have a single subscription in this this
// test but unsubscribing from the single channel indicates // test but unsubscribing from the single channel indicates
// that one subscriber still exists, let's dig into this. // that one subscriber still exists, let's dig into this.