The Laravel team released v13.40.0 with callbacks for queue jobs and scheduled tasks that run too long, commit IDs for checking whether a read replica has a write, insertBefore()
and insertAfter()
for the middleware stack, a strict
flag on request input helpers, and a security fix for the Concurrency
process driver.
Queue::whenJobRunsLongerThan()
andSchedule::whenTaskRunsLongerThan()
DB::getLastCommitId()
andDB::hasCommitId()
for read replicas- Insert middleware before or after a built-in middleware
- A
strict
flag forinteger()
,float()
,boolean()
, andstring()
- Signed result output for
Concurrency::run()
with the process driver - Transaction fixes for lost connections and lock wait timeouts
Alerts for Long-Running Jobs and Scheduled Tasks
Jack Bayliss added Queue::whenJobRunsLongerThan()
, which runs a callback when a job attempt takes longer than a threshold. Laravel already has DB::whenQueryingForLongerThan()
and similar methods for requests and commands, but not for queued jobs:
use Carbon\CarbonInterval; use Illuminate\Support\Facades\Queue; Queue::whenJobRunsLongerThan(CarbonInterval::seconds(90), function ($job, $duration) { Log::warning("{$job->resolveName()} took {$duration}ms"); });
The callback listens to the JobAttempted
event, so it also runs for attempts that fail or are released. A plain number is read as milliseconds, and the duration passed to the…