SerializesModels's firstOrFail doesn't honor $tries #53194
Unanswered
alejandrovelez7
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Laravel Version
9.52.16
PHP Version
8.1.29
Database Driver & Version
No response
Description
Context
When a job uses
SerializesModels
thefirstOrFail
here doesn't allow the job to retry.We occasionally run into connection issues like (
SQLSTATE[HY000] [2002] Operation now in progress
) with our database while processing jobs, and these don't indicate the model itself doesn't exist. We'd like to be able to retry the job in this case.If we upgrade to 11.24.0 will we no longer experience this because we'll have #52759 ?
Steps To Reproduce
For a simple example, I'm using Spatie's laravel webhook client which uses
SerializesModels
for theWebhookCall
in their jobs.We can extend their webhook job like so ->
If we dispatch this job onto a horizon queue via
ProcessWebhookJob::dispatch(new Spatie\WebhookClient\Models\WebhookCall())
the model will not be found, but the tries will not be honored, and the job will go straight intofailed_jobs
.This seems like a design choice (which is fine), but what's the workaround for this? I've attempted to override the
failed
function, but it is not being called.I've also tried to include custom middleware like this:
But this is also not being called on failures.
Beta Was this translation helpful? Give feedback.
All reactions