@@ -80,7 +80,7 @@ public function connect()
8080 };
8181
8282 $ that ->resolverPromises [Message::TYPE_AAAA ] = $ that ->resolve (Message::TYPE_AAAA , $ reject )->then ($ lookupResolve (Message::TYPE_AAAA ));
83- $ that ->resolverPromises [Message::TYPE_A ] = $ that ->resolve (Message::TYPE_A , $ reject )->then (function ($ ips ) use ($ that , &$ timer ) {
83+ $ that ->resolverPromises [Message::TYPE_A ] = $ that ->resolve (Message::TYPE_A , $ reject )->then (function (array $ ips ) use ($ that , &$ timer ) {
8484 // happy path: IPv6 has resolved already, continue with IPv4 addresses
8585 if ($ that ->resolved [Message::TYPE_AAAA ] === true ) {
8686 return $ ips ;
@@ -112,22 +112,24 @@ public function connect()
112112
113113 /**
114114 * @internal
115+ * @param int $type DNS query type
116+ * @param callable $reject
117+ * @return \React\Promise\PromiseInterface<string[],\Exception> Returns a promise
118+ * that resolves list of IP addresses on success or rejects with an \Exception on error.
115119 */
116120 public function resolve ($ type , $ reject )
117121 {
118122 $ that = $ this ;
119- return $ that ->resolver ->resolveAll ($ that ->host , $ type )->then (null , function () use ($ type , $ reject , $ that ) {
123+ return $ that ->resolver ->resolveAll ($ that ->host , $ type )->then (null , function (\ Exception $ e ) use ($ type , $ reject , $ that ) {
120124 unset($ that ->resolverPromises [$ type ]);
121125 $ that ->resolved [$ type ] = true ;
122126
123- if ($ that ->hasBeenResolved () === false ) {
124- return ;
125- }
126-
127- if ($ that ->ipsCount === 0 ) {
127+ if ($ that ->hasBeenResolved () && $ that ->ipsCount === 0 ) {
128128 $ that ->resolverPromises = null ;
129- $ reject (new \RuntimeException ('Connection to ' . $ that ->uri . ' failed during DNS lookup: DNS error ' ));
129+ $ reject (new \RuntimeException ('Connection to ' . $ that ->uri . ' failed during DNS lookup: ' . $ e -> getMessage () ));
130130 }
131+
132+ throw $ e ;
131133 });
132134 }
133135
0 commit comments