Skip to content

Commit

Permalink
Issue #512 send_command("monitoring") is doomed to fail
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbprice committed Aug 21, 2015
1 parent 323d6a2 commit 575ade9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ RedisClient.prototype.on_ready = function () {
});
return;
} else if (this.monitoring) {
this.send_command("monitor");
this.send_command("monitor", []);
} else {
this.send_offline_queue();
}
Expand Down
22 changes: 22 additions & 0 deletions test/node_redis.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
// test but unsubscribing from the single channel indicates
// that one subscriber still exists, let's dig into this.
Expand Down

0 comments on commit 575ade9

Please sign in to comment.