diff --git a/src/Transport/HttpTransport.php b/src/Transport/HttpTransport.php index ed264e5fc..2e4f9d2ac 100644 --- a/src/Transport/HttpTransport.php +++ b/src/Transport/HttpTransport.php @@ -155,6 +155,9 @@ public function send(Event $event): Result ['exception' => $exception, 'event' => $event] ); + // No response was received, so this is recorded like a failed connection + ClientReportAggregator::getInstance()->addEvent($event, Reason::networkError()); + return new Result(ResultStatus::failed()); } diff --git a/tests/Transport/HttpTransportTest.php b/tests/Transport/HttpTransportTest.php index ad7604e39..538e0d04d 100644 --- a/tests/Transport/HttpTransportTest.php +++ b/tests/Transport/HttpTransportTest.php @@ -165,6 +165,10 @@ public static function sendDataProvider(): iterable public function testSendFailsDueToHttpClientException(): void { + SentrySdk::init()->bindClient(new Client(new Options([ + 'send_client_reports' => true, + ]), StubTransport::getInstance())); + $exception = new \Exception('foo'); $event = Event::createEvent(); @@ -198,6 +202,7 @@ public function testSendFailsDueToHttpClientException(): void $result = $transport->send($event); $this->assertSame(ResultStatus::failed(), $result->getStatus()); + $this->assertClientReports(['error' => ['network_error' => 1]]); } public function testRecordsClientReportWhenSerializationFails(): void