File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
Expand file tree Collapse file tree 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 {
9999 private slotsTimer : NodeJS . Timer ;
100100 private reconnectTimeout : NodeJS . Timer ;
101101 private isRefreshing = false ;
102+ private _refreshSlotsCacheCallbacks = [ ] ;
102103 private _autoPipelines : Map < string , typeof Pipeline > = new Map ( ) ;
103104 private _runningAutoPipelines : Set < string > = new Set ( ) ;
104105 private _readyDelayedCallbacks : Callback [ ] = [ ] ;
@@ -411,20 +412,23 @@ class Cluster extends Commander {
411412 * @ignore
412413 */
413414 refreshSlotsCache ( callback ?: Callback < void > ) : void {
415+ if ( callback ) {
416+ this . _refreshSlotsCacheCallbacks . push ( callback ) ;
417+ }
418+
414419 if ( this . isRefreshing ) {
415- if ( callback ) {
416- process . nextTick ( callback ) ;
417- }
418420 return ;
419421 }
422+
420423 this . isRefreshing = true ;
421424
422425 const _this = this ;
423426 const wrapper = ( error ?: Error ) => {
424427 this . isRefreshing = false ;
425- if ( callback ) {
428+ for ( const callback of this . _refreshSlotsCacheCallbacks ) {
426429 callback ( error ) ;
427430 }
431+ this . _refreshSlotsCacheCallbacks = [ ] ;
428432 } ;
429433
430434 const nodes = shuffle ( this . connectionPool . getNodes ( ) ) ;
You can’t perform that action at this time.
0 commit comments