darkninja462's avatar

Failing Jobs

When a user registers their welcome email gets pushed onto a job queue, when this queue is processed the job can sometimes fail if the user has subsequently been deleted. As when the job is processed it returns ModelNotFoundException as the User is type hinted in the constructor like so:

public function __construct(UserModel $user)
    {
        $this->user = $user;
    }

However this doesn't seem to trigger in the Queue::failing(); catcher I had written in EventServiceProvider::boot method. Is there something I'm missing? It does however successfully move into the failed jobs table.

Regards -Darkninja462

0 likes
2 replies
darkninja462's avatar

I had previously seen that page but to no avail, further debugging found out that the event is never fired, hence not being picked up by the failing listener.

It appears that, the ModelNotFound error is thrown when you call the $job->failed() command as this then tries to re-queue. (/illuminate/queue/Worker.php@logFailedJob Line: 350). Just before the illuminate.queue.after event is fired.

Please or to participate in this conversation.