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 #439 (and others): Stop assuming all "message" or "pmessage" replies are pubsub replies. Check pub_sub_mode as well.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
node_modules
|
node_modules
|
||||||
|
.tern-port
|
||||||
|
11
index.js
11
index.js
@@ -14,6 +14,12 @@ var net = require("net"),
|
|||||||
// can set this to true to enable for all connections
|
// can set this to true to enable for all connections
|
||||||
exports.debug_mode = false;
|
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
|
// hiredis might not be installed
|
||||||
try {
|
try {
|
||||||
require("./lib/parser/hiredis");
|
require("./lib/parser/hiredis");
|
||||||
@@ -602,7 +608,10 @@ RedisClient.prototype.return_reply = function (reply) {
|
|||||||
type = reply[0].toString();
|
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();
|
command_obj = this.command_queue.shift();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
11
test.js
11
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 () {
|
tests.HGETALL_NULL = function () {
|
||||||
var name = "HGETALL_NULL";
|
var name = "HGETALL_NULL";
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user