From eca7c2c9e89777af1ed938adbcf0f47cde46ee5c Mon Sep 17 00:00:00 2001 From: Martin Linzmayer Date: Thu, 19 Nov 2026 15:16:24 +0100 Subject: [PATCH] fix(client-reports): record events dropped by client exception --- src/Transport/HttpTransport.php | 3 +++ tests/Transport/HttpTransportTest.php | 5 +++++ 2 files changed, 8 insertions(+) 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