Open
Description
Laravel Version
12.19.3
PHP Version
8.4.8
Database Driver & Version
No response
Description
Not exactly sure if this should be categorised as a bug, but it is definitely unexpected / unwanted behaviour: the new FailOnException
job middleware doesn't seem to work as expected in conjunction with the ThrottlesExceptions
job middleware. When both are specified as middleware the job seems to be attempted multiple times regardless. I have only tested this out with the "redis" queue driver.
Steps To Reproduce
The job below may be used to reproduce the problem. When both middlewares are active the failing job will be re-attempted until throttling kicks in and finally fails on job timeout. When you remove / comment out the ThrottlesExceptions
middleware things work like expected.
<?php
namespace App\Jobs;
use Carbon\CarbonImmutable;
use DateTimeImmutable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\Queueable;
use Illuminate\Queue\Middleware\FailOnException;
use Illuminate\Queue\Middleware\ThrottlesExceptions;
use Throwable;
class FailingJob implements ShouldQueue
{
use Queueable;
/**
* Create a new job instance.
*/
public function __construct()
{
//
}
/**
* Execute the job.
*/
public function handle(): void
{
throw new \Exception('Hey now!');
}
/**
* Get the middleware the job should pass through.
*
* @return array<int, object>
*/
public function middleware(): array
{
return [
new FailOnException([\Exception::class]),
new ThrottlesExceptions(10, 60)->report(
fn (Throwable $throwable): bool => $throwable instanceof \Exception,
),
];
}
/**
* Determine the time at which the job should timeout.
*/
public function retryUntil(): DateTimeImmutable
{
return CarbonImmutable::now()->addMinutes(2);
}
}
Metadata
Metadata
Assignees
Labels
No labels