Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Catch all exceptions thrown while sending an event #899

Merged
merged 6 commits into from
Oct 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
}
}
}
}