Skip to content
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

Exceptions in failed Jobs running in queue worker aren't reported to bugsnag. #535

Closed
bernardwiesner opened this issue Apr 9, 2024 · 4 comments
Labels
awaiting feedback Awaiting a response from a customer. Will be automatically closed after approximately 2 weeks.

Comments

@bernardwiesner
Copy link

Describe the bug

If there is an exception in a Job running through the laravel queue worker, and the job fails after the max tried attempts due to the exception, the exception is not reported to bugsnag. This is due to the queue worker being a long lived process that catches exceptions if they occur.

The only way to report these errors is to define in every Job a failed method and report the exception there.

However this is tedious to do for every Job. There should at least be an option in bugsnag to report failed job exceptions.

FYI: I also have to set Bugsnag::setBatchSending(false) in AppServiceProvider so the exception can be reported since queue worker does not exit on its own.

Steps to reproduce

  • Have a running queue worker (php artisan queue:work)
  • Create a Job that throws an Exception.
  • Exception is not reported to bugsnag

Environment

  • Bugsnag version: 2.26
  • PHP version: 8.1
  • Composer version: 2.6
  • Laravel version: 10.10
@mclack
Copy link

mclack commented May 9, 2024

Hi @bernardwiesner

Apologies for the delay in response.

We would expect these exceptions to be reported without needing to define a failed method in each job. We'd be interested to see your BugSnag configuration code, as well as whether you have any discard rules set up on your BugSnag dashboard, or if you are discarding any events from your app within an on-error callback.

As this is a public thread, please feel free to share any additional details with us directly by contacting support@bugsnag.com.

@mclack mclack added the awaiting feedback Awaiting a response from a customer. Will be automatically closed after approximately 2 weeks. label May 9, 2024
@bernardwiesner
Copy link
Author

Hi @mclack

Thanks for the reply.

I do not have any discard rules set. Could you refer me to the block of code in this repo that has the logic to deal a failure inside a Job to be reported to bugsnag?

As you know laravel is catching exceptions inside the queue worker and just calling the failed method, and emitting some events, but I don't think you are listening to any of those events.

If you could refer me to those code where the logic for dealing with failed jobs in the queue worker is implemented that would be very helpful, thanks!

@clr182
Copy link

clr182 commented May 29, 2024

Hi @bernardwiesner

Thank you for confirming.

You can find more information on the handling of unhandled errors in this repo here.

We believe instances of the errors you have highlighted should be captured and we do have test fixtures in place to test against such a case (here & here). However, for further investigation would it be possible for you to reproduce this issue and try sending these errors to an external webhook? Alternatively, if you could also share any error logging received based off of this unhandled crash inside a job.

As this is a public forum, please feel free to reach out to us at support@bugsnag.com to share this additional information.

@clr182
Copy link

clr182 commented Jun 13, 2024

Hi @bernardwiesner

As this thread has not seen any activity for some time I am going to close this issue out.
If you would like to continue this investigation please reach out and we can reopen this issue.

@clr182 clr182 closed this as completed Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting feedback Awaiting a response from a customer. Will be automatically closed after approximately 2 weeks.
Projects
None yet
Development

No branches or pull requests

3 participants