Skip to content

Commit

Permalink
Catch all exceptions thrown while sending an event (#899)
Browse files Browse the repository at this point in the history
  • Loading branch information
HazAT authored and ste93cry committed Oct 9, 2019
1 parent a0d0381 commit 61845ad
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

- Fix handling of fifth argument in the error handler (#892)
- Catch exception from vendors in `Sentry\Transport\HttpTransport` (#899)

## 2.2.1 (2019-09-23)

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ cs-dry-run:
vendor/bin/php-cs-fixer fix --config=.php_cs --verbose --diff --dry-run

cs-fix:
vendor/bin/php-cs-fixer fix --config=.php_cs
vendor/bin/php-cs-fixer fix

phpstan:
vendor/bin/phpstan analyse
Expand Down
11 changes: 9 additions & 2 deletions src/Transport/HttpTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ public function send(Event $event): ?string
if ($this->delaySendingUntilShutdown) {
$this->pendingRequests[] = $promise;
} else {
$promise->wait(false);
try {
$promise->wait();
} catch (\Exception $exception) {
return null;
}
}

return $event->getId();
Expand All @@ -119,7 +123,10 @@ public function send(Event $event): ?string
private function cleanupPendingRequests(): void
{
while ($promise = array_pop($this->pendingRequests)) {
$promise->wait(false);
try {
$promise->wait();
} catch (\Exception $exception) {
}
}
}
}

0 comments on commit 61845ad

Please # to comment.