Skip to content

[fix] queue consumption: catch throwable for processing errors #1114

New issue

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

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

Already on GitHub? Sign in to your account

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
6 changes: 3 additions & 3 deletions pkg/enqueue/Consumption/Context/ProcessorException.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class ProcessorException
private $message;

/**
* @var \Exception
* @var \Throwable
*/
private $exception;

Expand All @@ -44,7 +44,7 @@ final class ProcessorException
*/
private $logger;

public function __construct(Context $context, Consumer $consumer, Message $message, \Exception $exception, int $receivedAt, LoggerInterface $logger)
public function __construct(Context $context, Consumer $consumer, Message $message, \Throwable $exception, int $receivedAt, LoggerInterface $logger)
{
$this->context = $context;
$this->consumer = $consumer;
Expand All @@ -69,7 +69,7 @@ public function getMessage(): Message
return $this->message;
}

public function getException(): \Exception
public function getException(): \Throwable
{
return $this->exception;
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/enqueue/Consumption/QueueConsumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public function consume(ExtensionInterface $runtimeExtension = null): void
if (null === $result) {
try {
$result = $processor->process($message, $this->interopContext);
} catch (\Exception $e) {
} catch (\Exception | \Throwable $e) {
$result = $this->onProcessorException($extension, $consumer, $message, $e, $receivedAt);
}
}
Expand Down Expand Up @@ -303,7 +303,7 @@ private function onEnd(ExtensionInterface $extension, int $startTime, ?int $exit
*
* https://github.com/symfony/symfony/blob/cbe289517470eeea27162fd2d523eb29c95f775f/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php#L77
*/
private function onProcessorException(ExtensionInterface $extension, Consumer $consumer, Message $message, \Exception $exception, int $receivedAt)
private function onProcessorException(ExtensionInterface $extension, Consumer $consumer, Message $message, \Throwable $exception, int $receivedAt)
{
$processorException = new ProcessorException($this->interopContext, $consumer, $message, $exception, $receivedAt, $this->logger);

Expand Down