diff --git a/README.md b/README.md index 214e64967d..f818dc6d7a 100644 --- a/README.md +++ b/README.md @@ -182,7 +182,7 @@ port and host are probably fine and you don't need to supply any arguments. `cre * `path`: *null*; The unix socket string to connect to * `parser`: *hiredis*; Which Redis protocol reply parser to use. If `hiredis` is not installed it will fallback to `javascript`. * `return_buffers`: *false*; If set to `true`, then all replies will be sent to callbacks as Buffers instead of Strings. -* `detect_buffers`: *false*; If set to `true`, then replies will be sent to callbacks as Buffers +* `detect_buffers`: *false*; If set to `true`, then replies will be sent to callbacks as Buffers. Please be aware that this can't work properly with the pubsub mode. A subscriber has to either always return strings or buffers. if any of the input arguments to the original command were Buffers. This option lets you switch between Buffers and Strings on a per-command basis, whereas `return_buffers` applies to every command on a client. diff --git a/changelog.md b/changelog.md index 946fa27555..3121a92763 100644 --- a/changelog.md +++ b/changelog.md @@ -23,6 +23,7 @@ Bugfixes - Fixed .multi / .batch used with Node.js 0.10.x not working properly after a reconnect ([@BridgeAR](https://github.com/BridgeAR)) - Fixed fired but not yet returned commands not being rejected after a connection loss ([@BridgeAR](https://github.com/BridgeAR)) - Fixed connect_timeout not respected if no connection has ever been established ([@gagle](https://github.com/gagle) & [@benjie](https://github.com/benjie)) +- Fixed return_buffers in pub sub mode ([@komachi](https://github.com/komachi)) ## v.2.2.5 - 18 Oct, 2015 diff --git a/index.js b/index.js index ebb5cba87a..cf4f4fb8e9 100644 --- a/index.js +++ b/index.js @@ -653,7 +653,7 @@ RedisClient.prototype.return_reply = function (reply) { if (type === 'message') { this.emit('message', reply[1], reply[2]); // channel, message } else if (type === 'pmessage') { - this.emit('pmessage', reply[1], reply[2], reply[3]); // pattern, channel, message + this.emit('pmessage', reply[1].toString(), reply[2], reply[3]); // pattern, channel, message } else if (type === 'subscribe' || type === 'unsubscribe' || type === 'psubscribe' || type === 'punsubscribe') { if (reply[2] === 0) { this.pub_sub_mode = false;