Skip to content

Commit

Permalink
support for sentry bundle v5
Browse files Browse the repository at this point in the history
  • Loading branch information
FluffyDiscord committed Sep 26, 2024
1 parent 9717f44 commit 49d489b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/Worker/CentrifugoWorker.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use FluffyDiscord\RoadRunnerBundle\Event\Worker\WorkerBootingEvent;
use FluffyDiscord\RoadRunnerBundle\Exception\NoCentrifugoResponseProvidedException;
use FluffyDiscord\RoadRunnerBundle\Exception\UnsupportedCentrifugoRequestTypeException;
use GuzzleHttp\Promise\PromiseInterface;
use RoadRunner\Centrifugal\API\DTO\V1\DisconnectResponse;
use RoadRunner\Centrifugo\CentrifugoWorker as RoadRunnerCentrifugoWorker;
use RoadRunner\Centrifugo\Payload\ConnectResponse;
Expand Down Expand Up @@ -89,7 +90,12 @@ public function start(): void
$this->sentryHubInterface?->captureException($throwable);
$request->error(500, (string)$throwable);
} finally {
$this->sentryHubInterface?->getClient()?->flush()->wait(false);
$result = $this->sentryHubInterface?->getClient()?->flush();

// sentry v4 compatibility
if($result instanceof PromiseInterface) {
$result->wait(false);
}
$this->sentryHubInterface?->popScope();
}
}
Expand Down
9 changes: 8 additions & 1 deletion src/Worker/HttpWorker.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use FluffyDiscord\RoadRunnerBundle\Factory\DefaultResponseWrapper;
use FluffyDiscord\RoadRunnerBundle\Factory\StreamedJsonResponseWrapper;
use FluffyDiscord\RoadRunnerBundle\Factory\StreamedResponseWrapper;
use GuzzleHttp\Promise\PromiseInterface;
use Nyholm\Psr7;
use Sentry\State\HubInterface as SentryHubInterface;
use Spiral\RoadRunner;
Expand Down Expand Up @@ -93,7 +94,13 @@ public function start(): void
$worker->getWorker()->error((string)$throwable);

} finally {
$this->sentryHubInterface?->getClient()?->flush()->wait(false);
$result = $this->sentryHubInterface?->getClient()?->flush();

// sentry v4 compatibility
if($result instanceof PromiseInterface) {
$result->wait(false);
}

$this->sentryHubInterface?->popScope();
}
}
Expand Down

0 comments on commit 49d489b

Please sign in to comment.