You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
Detect is an incoming "reply" is in fact a pubsub message. If so, do not pop the command queue.
This fixes an issue where the command queue gets popped prematurely by pubsub messages, leading to callbacks for those commands not being invoked. Close #360. Signed-off-by: DTrejo <david.daniel.trejo@gmail.com>
This commit is contained in:
14
index.js
14
index.js
@@ -562,8 +562,18 @@ function reply_to_strings(reply) {
|
||||
RedisClient.prototype.return_reply = function (reply) {
|
||||
var command_obj, len, type, timestamp, argindex, args, queue_len;
|
||||
|
||||
command_obj = this.command_queue.shift(),
|
||||
queue_len = this.command_queue.getLength();
|
||||
// If the "reply" here is actually a message received asynchronously due to a
|
||||
// pubsub subscription, don't pop the command queue as we'll only be consuming
|
||||
// the head command prematurely.
|
||||
if (Array.isArray(reply) && reply.length > 0 && reply[0]) {
|
||||
type = reply[0].toString();
|
||||
}
|
||||
|
||||
if (type !== 'message' && type !== 'pmessage') {
|
||||
command_obj = this.command_queue.shift();
|
||||
}
|
||||
|
||||
queue_len = this.command_queue.getLength();
|
||||
|
||||
if (this.pub_sub_mode === false && queue_len === 0) {
|
||||
this.emit("idle");
|
||||
|
Reference in New Issue
Block a user