From c81f85576cca0e7afc8c6b51472d8fcba6b1c058 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Fri, 5 May 2017 18:17:15 +0200 Subject: [PATCH] chore: emit ready when all commands are done --- index.js | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/index.js b/index.js index 296bef97bd..79af798b50 100644 --- a/index.js +++ b/index.js @@ -275,7 +275,7 @@ RedisClient.prototype.warn = function (msg) { RedisClient.prototype.flushAndError = function (errorAttributes, options) { options = options || {}; var aggregatedErrors = []; - var queueNames = options.queues || ['commandQueue', 'offlineQueue']; // Flush the commandQueue first to keep the order intakt + var queueNames = options.queues || ['commandQueue', 'offlineQueue']; // Flush the commandQueue first to keep the order intact for (var i = 0; i < queueNames.length; i++) { // If the command was fired it might have been processed so far if (queueNames[i] === 'commandQueue') { @@ -386,23 +386,12 @@ RedisClient.prototype.onReady = function () { } var callbackCount = Object.keys(this.subscriptionSet).length; if (!this.options.disableResubscribing && callbackCount) { - // only emit 'ready' when all subscriptions were made again - // TODO: Remove the countdown for ready here. This is not coherent with all other modes and should therefore not be handled special - // We know we are ready as soon as all commands were fired - var callback = function () { - callbackCount--; - if (callbackCount === 0) { - self.emit('ready'); - } - }; debug('Sending pub/sub onReady commands'); for (var key in this.subscriptionSet) { var command = key.slice(0, key.indexOf('_')); var args = this.subscriptionSet[key]; - this[command]([args], callback); + this[command]([args]); } - this.sendOfflineQueue(); - return; } this.sendOfflineQueue(); this.emit('ready');