diff --git a/src/ProxyConnector.php b/src/ProxyConnector.php index 165e8ba..d7f2863 100644 --- a/src/ProxyConnector.php +++ b/src/ProxyConnector.php @@ -159,6 +159,8 @@ public function connect($uri) // either close active connection or cancel pending connection attempt $connecting->then(function (ConnectionInterface $stream) { $stream->close(); + }, function () { + // ignore to avoid reporting unhandled rejection }); $connecting->cancel(); }); diff --git a/tests/ProxyConnectorTest.php b/tests/ProxyConnectorTest.php index 0b8c155..f2d5795 100644 --- a/tests/ProxyConnectorTest.php +++ b/tests/ProxyConnectorTest.php @@ -542,6 +542,9 @@ public function testRejectedConnectionShouldNotCreateGarbageCycles() $proxy = new ProxyConnector('proxy.example.com', $this->connector); $promise = $proxy->connect('google.com:80'); + + $promise->then(null, $this->expectCallableOnce()); // avoid reporting unhandled rejection + unset($promise); $this->assertEquals(0, gc_collect_cycles());