bugsnag / bugsnag-symfony

BugSnag notifier for the Symfony PHP framework. Monitor and report errors in your Symfony apps.
https://docs.bugsnag.com/platforms/php/symfony
MIT License
43 stars 21 forks source link

Listen to WorkerMessageFailedEvent #88

Closed MatTheCat closed 3 years ago

MatTheCat commented 4 years ago

Expected behavior

Exceptions thrown in MessageHandlerInterface are catched by the BugsnagListener.

Observed behavior

This isn't the case.

Steps to reproduce

Have a MessageHandlerInterface throw an exception.

Version

I suspect all versions are impacted though.

Additional information

Every exception thrown inside a message handler is catched by the worker so it can continue working so there is no kernel.exception. Instead a WorkerMessageFailedEvent is dispatched so the BugsnagListener should also listen to it.

rjharrison commented 4 years ago

Hi Mathieu.

I've labelled this a feature request.

Would it always be appropriate to trigger a Bugsnag notification on every WorkerMessageFailedEvent? It seems like there is a retry mechanism designed to allow workers to fail, so potentially we could trigger a notification but then the worker succeed on a retry. I wonder whether we could hook into the failure_transport and send notifications there. My gut feeling however is that this would be the responsibility of the developer to handle (i.e. implement a failure transport that triggers a Bugsnag notification as well as handling the failed message).

Have you also looked at UnrecoverableMessageHandlingException? I think if you throw one of these it'll bypass the catch and your exception would reach Bugsnag.

MatTheCat commented 4 years ago

Yep it was a feature request!

WorkerMessageFailedEvent exposes a willRetry method; I would except the exception to reach bugsnag when it returns false. That way you only have one exception if all retries failed.

yousif-bugsnag commented 3 years ago

Released in v1.10.0 🎉