Back to Blog
Laravel 13.34 Counts Worker Crashes Toward maxExceptions
Laravel 13.34 lets opted-in jobs treat OOM kills and worker crashes as exceptions against maxExceptions, so retryUntil jobs stop looping forever.
Back
Engineering
Table of contents
Laravel 13.34 Counts Worker Crashes Toward maxExceptions
A queued job that throws counts toward $maxExceptions. A job whose worker dies mid-run (OOM kill, segfault, container stop) usually does not. Pair that with retryUntil() and a rate limiter, and a bad job can burn workers until the deadline.
Laravel 13.34.0 adds an opt-in fix. Mark the job, and a crashed attempt counts as one exception.
Quick Answer
Ship laravel/framework 13.34.0 or newer. On jobs that use maxExceptions (especially with retryUntil() and $tries = 0), add the attribute or property:
php
use Illuminate\Queue\Attributes\CountCrashesAsExceptions;
use Illuminate\Queue\Attributes\MaxExceptions;
#[MaxExceptions(3), CountCrashesAsExceptions]
class ProcessPodcast implements ShouldQueue
{
public $tries = 0;
public function retryUntil(): \DateTime
{
return now()->addHour();
}
}Or set public $countCrashesAsExceptions = true; on the job. You still need a maxExceptions limit. Without it, the flag does nothing useful.
The hole this closes
maxExceptions exists so a job can release many times (rate limits, locks) without failing, but still fail after a few real exceptions. Worker crashes sat outside that counter.
William Julian-Vicary's PR (#61737) spells out the pain case: media or plugin work that OOMs or segfaults, $tries = 0 because a rate limiter already burns attempts, and retryUntil() as the only backstop. Until the deadline, the queue keeps replaying the same crash. On Laravel Cloud, that burned compute in a loop.
I have hit the same class of bug in Docker and Kubernetes. The kernel OOM-killer or a deploy SIGKILL does not look like a PHP exception. The job comes back. Horizon or queue:work under Supervisor looks "healthy" while you pay for retries that never learn.
How the opt-in works
Official queues docs (13.x) now document it under Max Exceptions.
When CountCrashesAsExceptions is present, the worker stores a marker in your application cache while the job runs. If that marker is still there on the next attempt, the previous attempt died, and Laravel counts it as an exception toward maxExceptions.
Normal completions and worker-managed timeouts are not treated as crashes for this counter. The feature is opt-in because each attempt adds two cache calls. Use a cache store every worker can see (Redis, database, Memcached). Per-container array or file cache will not share the marker across workers.
The official Laravel changelog for September 2026 summarizes the same behavior: opt in with the attribute or $countCrashesAsExceptions, and unexpected worker termination counts toward the exception limit.
Same release: timeouts that notify the job
13.34 also improves interruptible jobs. Jack Bayliss's PR (#61651) updates the worker so a job that implements Interruptible gets SIGALRM when it hits its timeout. Before, timeouts could kill the worker without giving the job a chance to run interrupted(). Now the job can save progress, and the worker still dispatches JobInterrupted (added in 13.31).
That pairs with crash counting in spirit: production queues need clear failure accounting and a chance to clean up, not silent death.
Also useful from the same tag: JobProcessed now exposes a duration property in milliseconds (#61672), and queue:flush accepts --queue so you can clear one queue's failed jobs after an outage (#61630).
My take
I would not turn this on for every job. Opt in on the ones that already use maxExceptions with long retryUntil() windows, heavy memory work, or native extensions that can segfault. Leave lightweight jobs alone. Two cache hits per attempt is cheap on Redis. It is not free on a hot path you do not need.
Also check your process manager. Crash counting stops the job from looping forever. It does not stop the OOM. Fix memory limits, chunk sizes, and image/ffmpeg pipelines separately. Treat this attribute as a circuit breaker, not a cure.
If you run Horizon or multiple containers, confirm workers share one cache connection before you rely on the marker. That requirement is easy to miss when local array cache "works" in a single process.
Sources
- Laravel queues docs (13.x): Max Exceptions / CountCrashesAsExceptions
- Laravel framework v13.34.0 release
- laravel/framework PR #61737 (count worker crashes toward maxExceptions)
- laravel/framework PR #61651 (notify Interruptible jobs before timeout)
- Laravel docs changelog: Count Worker Crashes
- Laravel News: Count Worker Crashes as Job Exceptions in Laravel 13.34
As of this writing, laravel/framework v13.43.0 is the current release on GitHub and Packagist. The crash-counting feature still matches the 13.x queue docs linked above.
Checked on 2026-11-20
Comments
No comments yet
Loading comments...