diff --git a/index.js b/index.js index 585ca73e81..77cebdfa7d 100644 --- a/index.js +++ b/index.js @@ -570,6 +570,8 @@ RedisClient.prototype.return_reply = function (reply) { if (this.debug_mode) { console.log("All subscriptions removed, exiting pub/sub mode"); } + } else { + this.pub_sub_mode = true; } // subscribe commands take an optional callback and also emit an event, but only the first response is included in the callback // TODO - document this or fix it so it works in a more obvious way diff --git a/tests/re_sub_test.js b/tests/re_sub_test.js new file mode 100644 index 0000000000..64b8f31287 --- /dev/null +++ b/tests/re_sub_test.js @@ -0,0 +1,14 @@ +var client = require('../index').createClient() + , client2 = require('../index').createClient() + , assert = require('assert'); + +client.once('subscribe', function (channel, count) { + client.unsubscribe('x'); + client.subscribe('x', function () { + client.quit(); + client2.quit(); + }); + client2.publish('x', 'hi'); +}); + +client.subscribe('x');