File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ export default class ConnectionPool extends EventEmitter {
2929
3030  getNodes ( role : NodeRole  =  "all" ) : Redis [ ]  { 
3131    const  nodeRecords  =  this . nodeRecords [ role ] ; 
32-     return  Object . keys ( nodeRecords ) . map ( ( key )  =>  nodeRecords [ key ] . redis ) ; 
32+     return  Object . keys ( nodeRecords ) . map ( ( key )  =>  nodeRecords [ key ] ? .redis ) ; 
3333  } 
3434
3535  getInstanceByKey ( key : NodeKey ) : Redis  { 
@@ -39,7 +39,7 @@ export default class ConnectionPool extends EventEmitter {
3939  getSampleInstance ( role : NodeRole ) : Redis  { 
4040    const  keys  =  Object . keys ( this . nodeRecords [ role ] ) ; 
4141    const  sampleKey  =  sample ( keys ) ; 
42-     return  this . nodeRecords [ role ] [ sampleKey ] . redis ; 
42+     return  this . nodeRecords [ role ] [ sampleKey ] ? .redis ; 
4343  } 
4444
4545  /** 
Original file line number Diff line number Diff line change 1+ import  {  expect  }  from  "chai" ; 
2+ 
3+ import  ConnectionPool  from  "../../../lib/cluster/ConnectionPool" ; 
4+ 
5+ describe ( "The cluster connection pool" ,  ( )  =>  { 
6+   describe ( "when not connected" ,  ( )  =>  { 
7+     it ( "does not throw when fetching a sample node" ,  ( )  =>  { 
8+       expect ( new  ConnectionPool ( { } ) . getSampleInstance ( "all" ) ) . to . be . undefined ; 
9+       expect ( new  ConnectionPool ( { } ) . getNodes ( "all" ) ) . to . be . eql ( [ ] ) ; 
10+     } ) ; 
11+   } ) ; 
12+ } ) ; 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments