Skip to content

Commit 6b1e789

Browse files
committed
Merge pull request #749 from danielbprice/master
Issue #512 send_command("monitoring") is doomed to fail
2 parents 323d6a2 + 575ade9 commit 6b1e789

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ RedisClient.prototype.on_ready = function () {
369369
});
370370
return;
371371
} else if (this.monitoring) {
372-
this.send_command("monitor");
372+
this.send_command("monitor", []);
373373
} else {
374374
this.send_offline_queue();
375375
}

test/node_redis.spec.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,28 @@ describe("The node_redis client", function () {
8484
});
8585
});
8686

87+
it("reconnects properly when monitoring", function (done) {
88+
client.on("reconnecting", function on_recon(params) {
89+
client.on("ready", function on_ready() {
90+
assert.strictEqual(client.monitoring, true, "monitoring after reconnect");
91+
client.removeListener("ready", on_ready);
92+
client.removeListener("reconnecting", on_recon);
93+
done();
94+
});
95+
});
96+
97+
assert.strictEqual(client.monitoring, false, "monitoring off at start");
98+
client.set("recon 1", "one");
99+
client.monitor(function (err, res) {
100+
assert.strictEqual(client.monitoring, true, "monitoring on after monitor()");
101+
client.set("recon 2", "two", function (err, res) {
102+
// Do not do this in normal programs. This is to simulate the server closing on us.
103+
// For orderly shutdown in normal programs, do client.quit()
104+
client.stream.destroy();
105+
});
106+
});
107+
});
108+
87109
// TODO: we should only have a single subscription in this this
88110
// test but unsubscribing from the single channel indicates
89111
// that one subscriber still exists, let's dig into this.

0 commit comments

Comments
 (0)