File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -337,7 +337,7 @@ Cluster.prototype.refreshSlotsCache = function (callback) {
337337} ;
338338
339339/**
340- * Flush offline queue and command queue with error.
340+ * Flush offline queue with error.
341341 *
342342 * @param {Error } error - The error object to send to the commands
343343 * @private
Original file line number Diff line number Diff line change @@ -315,9 +315,6 @@ Redis.prototype.disconnect = function (reconnect) {
315315 if ( this . status === 'wait' ) {
316316 eventHandler . closeHandler ( this ) ( ) ;
317317 } else {
318- if ( this . stream ) {
319- this . stream . removeAllListeners ( 'data' ) ;
320- }
321318 this . connector . disconnect ( ) ;
322319 }
323320} ;
@@ -359,9 +356,14 @@ Redis.prototype.flushQueue = function (error) {
359356 item . command . reject ( error ) ;
360357 }
361358
362- while ( this . commandQueue . length > 0 ) {
363- item = this . commandQueue . shift ( ) ;
364- item . command . reject ( error ) ;
359+ if ( this . commandQueue . length > 0 ) {
360+ if ( this . stream ) {
361+ this . stream . removeAllListeners ( 'data' ) ;
362+ }
363+ while ( this . commandQueue . length > 0 ) {
364+ item = this . commandQueue . shift ( ) ;
365+ item . command . reject ( error ) ;
366+ }
365367 }
366368} ;
367369
You can’t perform that action at this time.
0 commit comments