You've already forked node-redis
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:
2
index.js
2
index.js
@@ -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();
|
||||||
}
|
}
|
||||||
|
@@ -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.
|
||||||
|
Reference in New Issue
Block a user