@@ -69,7 +69,7 @@ class Cluster extends EventEmitter {
69
69
private isRefreshing = false ;
70
70
public isCluster = true ;
71
71
private _autoPipelines : Map < string , typeof Pipeline > = new Map ( ) ;
72
- private _groupsIds : { [ key : string ] : number } = { } ;
72
+ private _groupsIds : { [ key : string ] : number } = { } ;
73
73
private _groupsBySlot : number [ ] = Array ( 16384 ) ;
74
74
private _runningAutoPipelines : Set < string > = new Set ( ) ;
75
75
private _readyDelayedCallbacks : CallbackFunction [ ] = [ ] ;
@@ -154,6 +154,13 @@ class Cluster extends EventEmitter {
154
154
}
155
155
}
156
156
157
+ clearAddedScriptHashesCleanInterval ( ) {
158
+ if ( this . _addedScriptHashesCleanInterval ) {
159
+ clearInterval ( this . _addedScriptHashesCleanInterval ) ;
160
+ this . _addedScriptHashesCleanInterval = null ;
161
+ }
162
+ }
163
+
157
164
resetNodesRefreshInterval ( ) {
158
165
if ( this . slotsTimer ) {
159
166
return ;
@@ -191,7 +198,7 @@ class Cluster extends EventEmitter {
191
198
}
192
199
193
200
// Make sure only one timer is active at a time
194
- clearInterval ( this . _addedScriptHashesCleanInterval ) ;
201
+ this . clearAddedScriptHashesCleanInterval ( ) ;
195
202
196
203
// Start the script cache cleaning
197
204
this . _addedScriptHashesCleanInterval = setInterval ( ( ) => {
@@ -272,12 +279,12 @@ class Cluster extends EventEmitter {
272
279
this . once ( "close" , this . handleCloseEvent . bind ( this ) ) ;
273
280
274
281
this . refreshSlotsCache (
275
- function ( err ) {
276
- if ( err && err . message === "Failed to refresh slots cache." ) {
277
- Redis . prototype . silentEmit . call ( this , "error" , err ) ;
278
- this . connectionPool . reset ( [ ] ) ;
279
- }
280
- } . bind ( this )
282
+ function ( err ) {
283
+ if ( err && err . message === "Failed to refresh slots cache." ) {
284
+ Redis . prototype . silentEmit . call ( this , "error" , err ) ;
285
+ this . connectionPool . reset ( [ ] ) ;
286
+ }
287
+ } . bind ( this )
281
288
) ;
282
289
this . subscriber . start ( ) ;
283
290
} )
@@ -300,6 +307,9 @@ class Cluster extends EventEmitter {
300
307
if ( reason ) {
301
308
debug ( "closed because %s" , reason ) ;
302
309
}
310
+
311
+ this . clearAddedScriptHashesCleanInterval ( ) ;
312
+
303
313
let retryDelay ;
304
314
if (
305
315
! this . manuallyClosing &&
@@ -339,8 +349,7 @@ class Cluster extends EventEmitter {
339
349
const status = this . status ;
340
350
this . setStatus ( "disconnecting" ) ;
341
351
342
- clearInterval ( this . _addedScriptHashesCleanInterval ) ;
343
- this . _addedScriptHashesCleanInterval = null ;
352
+ this . clearAddedScriptHashesCleanInterval ( ) ;
344
353
345
354
if ( ! reconnect ) {
346
355
this . manuallyClosing = true ;
@@ -372,8 +381,7 @@ class Cluster extends EventEmitter {
372
381
const status = this . status ;
373
382
this . setStatus ( "disconnecting" ) ;
374
383
375
- clearInterval ( this . _addedScriptHashesCleanInterval ) ;
376
- this . _addedScriptHashesCleanInterval = null ;
384
+ this . clearAddedScriptHashesCleanInterval ( ) ;
377
385
378
386
this . manuallyClosing = true ;
379
387
@@ -632,7 +640,8 @@ class Cluster extends EventEmitter {
632
640
} else {
633
641
_this . slots [ slot ] = [ key ] ;
634
642
}
635
- _this . _groupsBySlot [ slot ] = _this . _groupsIds [ _this . slots [ slot ] . join ( ';' ) ] ;
643
+ _this . _groupsBySlot [ slot ] =
644
+ _this . _groupsIds [ _this . slots [ slot ] . join ( ";" ) ] ;
636
645
_this . connectionPool . findOrCreate ( _this . natMapper ( key ) ) ;
637
646
tryConnection ( ) ;
638
647
debug ( "refreshing slot caches... (triggered by MOVED error)" ) ;
@@ -867,14 +876,14 @@ class Cluster extends EventEmitter {
867
876
}
868
877
869
878
// Assign to each node keys a numeric value to make autopipeline comparison faster.
870
- this . _groupsIds = Object . create ( null ) ;
879
+ this . _groupsIds = Object . create ( null ) ;
871
880
let j = 0 ;
872
881
for ( let i = 0 ; i < 16384 ; i ++ ) {
873
- const target = ( this . slots [ i ] || [ ] ) . join ( ';' ) ;
882
+ const target = ( this . slots [ i ] || [ ] ) . join ( ";" ) ;
874
883
875
884
if ( ! target . length ) {
876
885
this . _groupsBySlot [ i ] = undefined ;
877
- continue ;
886
+ continue ;
878
887
}
879
888
880
889
if ( ! this . _groupsIds [ target ] ) {
0 commit comments