diff --git a/Collector/ProfileClient.php b/Collector/ProfileClient.php index ec0cc5fd..6b414dbc 100644 --- a/Collector/ProfileClient.php +++ b/Collector/ProfileClient.php @@ -86,12 +86,14 @@ public function sendAsyncRequest(RequestInterface $request) $onFulfilled = function (ResponseInterface $response) use ($event, $stack) { $this->collectResponseInformations($response, $event, $stack); + $event->stop(); return $response; }; $onRejected = function (\Exception $exception) use ($event, $stack) { $this->collectExceptionInformations($exception, $event, $stack); + $event->stop(); throw $exception; }; @@ -100,8 +102,11 @@ public function sendAsyncRequest(RequestInterface $request) try { return $this->client->sendAsyncRequest($request)->then($onFulfilled, $onRejected); - } finally { + } catch (\Exception $e) { $event->stop(); + + throw $e; + } finally { if ($activateStack) { //We only activate the stack when created by the StackPlugin. $this->collector->activateStack($stack);