File tree 1 file changed +8
-4
lines changed
1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -99,6 +99,7 @@ class Cluster extends Commander {
99
99
private slotsTimer : NodeJS . Timer ;
100
100
private reconnectTimeout : NodeJS . Timer ;
101
101
private isRefreshing = false ;
102
+ private _refreshSlotsCacheCallbacks = [ ] ;
102
103
private _autoPipelines : Map < string , typeof Pipeline > = new Map ( ) ;
103
104
private _runningAutoPipelines : Set < string > = new Set ( ) ;
104
105
private _readyDelayedCallbacks : Callback [ ] = [ ] ;
@@ -411,20 +412,23 @@ class Cluster extends Commander {
411
412
* @ignore
412
413
*/
413
414
refreshSlotsCache ( callback ?: Callback < void > ) : void {
415
+ if ( callback ) {
416
+ this . _refreshSlotsCacheCallbacks . push ( callback ) ;
417
+ }
418
+
414
419
if ( this . isRefreshing ) {
415
- if ( callback ) {
416
- process . nextTick ( callback ) ;
417
- }
418
420
return ;
419
421
}
422
+
420
423
this . isRefreshing = true ;
421
424
422
425
const _this = this ;
423
426
const wrapper = ( error ?: Error ) => {
424
427
this . isRefreshing = false ;
425
- if ( callback ) {
428
+ for ( const callback of this . _refreshSlotsCacheCallbacks ) {
426
429
callback ( error ) ;
427
430
}
431
+ this . _refreshSlotsCacheCallbacks = [ ] ;
428
432
} ;
429
433
430
434
const nodes = shuffle ( this . connectionPool . getNodes ( ) ) ;
You can’t perform that action at this time.
0 commit comments