diff --git a/.gitignore b/.gitignore index 3c3629e647..6a59b3d64c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules +.tern-port diff --git a/index.js b/index.js index d16a15ff63..38606be769 100644 --- a/index.js +++ b/index.js @@ -14,6 +14,12 @@ var net = require("net"), // can set this to true to enable for all connections exports.debug_mode = false; +var arraySlice = Array.prototype.slice +function trace() { + if (!exports.debug_mode) return; + console.log.apply(null, arraySlice.call(arguments)) +} + // hiredis might not be installed try { require("./lib/parser/hiredis"); @@ -602,7 +608,10 @@ RedisClient.prototype.return_reply = function (reply) { type = reply[0].toString(); } - if (type !== 'message' && type !== 'pmessage') { + if (this.pub_sub_mode && (type == 'message' || type == 'pmessage')) { + trace("received pubsub message"); + } + else { command_obj = this.command_queue.shift(); } diff --git a/test.js b/test.js index 79907a0160..5e204bc2c7 100644 --- a/test.js +++ b/test.js @@ -1281,6 +1281,17 @@ tests.HGETALL = function () { }); }; +tests.HGETALL_MESSAGE = function () { + var name = "HGETALL_MESSAGE"; + client.hmset("msg_test", {message: "hello"}, require_string("OK", name)); + client.hgetall("msg_test", function (err, obj) { + assert.strictEqual(null, err, name + " result sent back unexpected error: " + err); + assert.strictEqual(1, Object.keys(obj).length, name); + assert.strictEqual(obj.message, "hello") + next(name); + }); +}; + tests.HGETALL_NULL = function () { var name = "HGETALL_NULL";