File tree Expand file tree Collapse file tree 2 files changed +191
-191
lines changed
test/integration/server-selection Expand file tree Collapse file tree 2 files changed +191
-191
lines changed Original file line number Diff line number Diff line change @@ -959,16 +959,16 @@ function processWaitQueue(topology: Topology) {
959
959
continue ;
960
960
}
961
961
962
+ let selectedServer ;
962
963
if ( selectedDescriptions . length === 0 ) {
963
964
topology [ kWaitQueue ] . push ( waitQueueMember ) ;
964
965
continue ;
965
- }
966
-
967
- let selectedServer ;
968
- if ( selectedDescriptions . length === 1 ) {
966
+ } else if ( selectedDescriptions . length === 1 ) {
969
967
selectedServer = topology . s . servers . get ( selectedDescriptions [ 0 ] . address ) ;
970
968
} else {
971
- const descriptions = shuffle ( selectedDescriptions , 2 ) ;
969
+ // don't shuffle the array if there are only two elements
970
+ const descriptions =
971
+ selectedDescriptions . length === 2 ? selectedDescriptions : shuffle ( selectedDescriptions , 2 ) ;
972
972
const server1 = topology . s . servers . get ( descriptions [ 0 ] . address ) ;
973
973
const server2 = topology . s . servers . get ( descriptions [ 1 ] . address ) ;
974
974
You can’t perform that action at this time.
0 commit comments