[13.x] Allow opting out of worker Job exception reporting#59308
[13.x] Allow opting out of worker Job exception reporting#59308taylorotwell merged 3 commits intolaravel:13.xfrom
Conversation
|
Thanks for submitting a PR! Note that draft PRs are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface. Pull requests that are abandoned in draft may be closed due to inactivity. |
|
Taking a look at this, I feel it is rather heavy handed. From what I can see, if Redis went away and an exception was being thrown whenever a job was being popped from the queue, you wouldn't ever have the exception reported. |
|
@timacdonald Thanks for the insight, I'm getting this reported via the DB driver atm via The problem is the worker reports every exception on every attempt, even when the job successfully retries, we get exceptions reported, and its not clear if its been retried or failed so we dig into it (to potentially put it back onto the queue manually) to find Laravel has already retried and the job succeeded If a blanket flag isn't preferred, I could just do something like the below to be more specific in runJob: if (static::$reportExceptionsOnRetry || $job->hasFailed()) {
$this->exceptions->report($e);
}Maybe there's a better way tho? So very open to a better way. Maybe we just ignore the exception our side🤷🏻 But it can come from a variety of jobs so its a bit painful and can cause a bit of panic See trace (ive anonymized bits but you get the idea)Marking as draft cause maybe you have a super easier way that I can't see 🙇🏻 |
|
Came back to this with fresh eyes and tightened the scope. The flag is now limited to This stops job exceptions bubbling up to Nightwatch/Flare/Sentry etc. visibility is still there via the JobExceptionOccurred and JobFailed events (which exposes $exception directly) for those who need it. I leave it to the Laravel gods, let me know if there are any questions. |
A non-breaking (better?) alternative for #59271
The worker reports every Job exception to the exception handler even when you have queue events wired up.
A job can throw, retry, succeed and you've already been paged by Nightwatch/Flare/Sentry for something that has resolved itself.
We already have events that provide full visibility into this lifecycle (JobExceptionOccurred, JobReleasedAfterException,
JobFailed), so I'd like to use those and stop the errors coming through.
This adds a static flag to opt out of exception reporting in
runJob(),getNextJob()etc is unaffected.