@@ -411,19 +411,26 @@ Cluster.prototype.sendCommand = function (command, stream, node) {
411
411
var _this = this ;
412
412
if ( ! node ) {
413
413
command . reject = function ( err ) {
414
+ var partialTry = _ . partial ( tryConnection , true ) ;
415
+
414
416
_this . handleError ( err , ttl , {
415
417
moved : function ( node , slot , hostPort ) {
416
418
debug ( 'command %s is moved to %s:%s' , command . name , hostPort [ 0 ] , hostPort [ 1 ] ) ;
417
- _this . slots [ slot ] . masterNode = node ;
419
+ var coveredSlot = _this . slots [ slot ] ;
420
+ if ( ! coveredSlot ) {
421
+ _this . slots [ slot ] = { masterNode : node , allNodes : [ node ] } ;
422
+ } else {
423
+ coveredSlot . masterNode = node ;
424
+ }
418
425
tryConnection ( ) ;
419
426
_this . refreshSlotsCache ( ) ;
420
427
} ,
421
428
ask : function ( node , slot , hostPort ) {
422
429
debug ( 'command %s is required to ask %s:%s' , command . name , hostPort [ 0 ] , hostPort [ 1 ] ) ;
423
430
tryConnection ( false , node ) ;
424
431
} ,
425
- clusterDown : tryConnection . bind ( null , true ) ,
426
- connectionClosed : tryConnection . bind ( null , true ) ,
432
+ clusterDown : partialTry ,
433
+ connectionClosed : partialTry ,
427
434
maxRedirections : function ( redirectionError ) {
428
435
reject . call ( command , redirectionError ) ;
429
436
} ,
0 commit comments