@@ -1251,15 +1251,7 @@ where
12511251 ) -> RedisResult < ConnectionMap < C > > {
12521252 let initial_nodes: Vec < ( String , Option < SocketAddr > ) > =
12531253 Self :: try_to_expand_initial_nodes ( initial_nodes) . await ;
1254-
1255- // HACK: Skip the last address to test if it's a "last node" issue
1256- let nodes_to_process = if initial_nodes. len ( ) > 1 {
1257- & initial_nodes[ ..initial_nodes. len ( ) - 1 ]
1258- } else {
1259- & initial_nodes[ ..]
1260- } ;
1261-
1262- let connections = stream:: iter ( nodes_to_process. iter ( ) . cloned ( ) )
1254+ let connections = stream:: iter ( initial_nodes. iter ( ) . cloned ( ) )
12631255 . map ( |( node_addr, socket_addr) | {
12641256 let mut params: ClusterParams = params. clone ( ) ;
12651257 let glide_connection_options = glide_connection_options. clone ( ) ;
@@ -1285,28 +1277,38 @@ where
12851277 result. map ( |node| ( node_address, node) )
12861278 }
12871279 } )
1288- . buffer_unordered ( nodes_to_process . len ( ) )
1280+ . buffer_unordered ( initial_nodes . len ( ) )
12891281 . fold (
12901282 (
1291- ConnectionsMap ( DashMap :: with_capacity ( nodes_to_process . len ( ) ) ) ,
1292- None ,
1283+ ConnectionsMap ( DashMap :: with_capacity ( initial_nodes . len ( ) ) ) ,
1284+ Vec :: new ( ) , // Collect ALL errors instead of just the last one
12931285 ) ,
1294- |connections : ( ConnectionMap < C > , Option < String > ) , addr_conn_res| async move {
1286+ |mut connections : ( ConnectionMap < C > , Vec < String > ) , addr_conn_res| async move {
12951287 match addr_conn_res {
12961288 Ok ( ( addr, node) ) => {
12971289 connections. 0 . 0 . insert ( addr, node) ;
1298- ( connections. 0 , None )
1290+ connections
1291+ }
1292+ Err ( e) => {
1293+ connections. 1 . push ( e. to_string ( ) ) ; // Collect all errors
1294+ connections
12991295 }
1300- Err ( e) => ( connections. 0 , Some ( e. to_string ( ) ) ) ,
13011296 }
13021297 } ,
13031298 )
13041299 . await ;
13051300 if connections. 0 . 0 . is_empty ( ) {
1301+ let error_message = if connections. 1 . is_empty ( ) {
1302+ "No errors reported" . to_string ( )
1303+ } else {
1304+ format ! ( "All {} connection attempts failed: [{}]" ,
1305+ connections. 1 . len( ) ,
1306+ connections. 1 . join( ", " ) )
1307+ } ;
13061308 return Err ( RedisError :: from ( (
13071309 ErrorKind :: IoError ,
13081310 "Failed to create initial connections" ,
1309- connections . 1 . unwrap_or ( "" . to_string ( ) ) ,
1311+ error_message ,
13101312 ) ) ) ;
13111313 }
13121314 info ! ( "Connected to initial nodes:\n {}" , connections. 0 ) ;
0 commit comments