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 3 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 --config=.php_cs.dist
HazAT marked this conversation as resolved.
Show resolved Hide resolved

phpstan:
vendor/bin/phpstan analyse
Expand Down
12 changes: 10 additions & 2 deletions src/Transport/HttpTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Sentry\Transport;

use Http\Client\Common\Exception\ClientErrorException;
use Http\Client\HttpAsyncClient as HttpAsyncClientInterface;
use Http\Message\RequestFactory as RequestFactoryInterface;
use Http\Promise\Promise as PromiseInterface;
Expand Down Expand Up @@ -106,7 +107,11 @@ public function send(Event $event): ?string
if ($this->delaySendingUntilShutdown) {
$this->pendingRequests[] = $promise;
} else {
$promise->wait(false);
try {
$promise->wait(false);
ste93cry marked this conversation as resolved.
Show resolved Hide resolved
} catch (ClientErrorException $e) {
ste93cry marked this conversation as resolved.
Show resolved Hide resolved
return null;
}
}

return $event->getId();
Expand All @@ -119,7 +124,10 @@ public function send(Event $event): ?string
private function cleanupPendingRequests(): void
{
while ($promise = array_pop($this->pendingRequests)) {
$promise->wait(false);
try {
$promise->wait(false);
ste93cry marked this conversation as resolved.
Show resolved Hide resolved
} catch (ClientErrorException $e) {
ste93cry marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
}