Laravel Magazine

[13.x] Laravel Worker Timeout Exit Code Is Now Overridable

Eric Van Johnson · News
[13.x] Laravel Worker Timeout Exit Code Is Now Overridable

@jackbayliss merged PR #60072 into laravel/framework on the 13.x branch, adding the ability to override the exit code the queue worker emits when a job times out.


The Problem

Some hosting providers treat the worker timeout exit code as a signal to restart every worker in the pool, not just the one that timed out. If a job times out three times in a row, the provider cascades a full worker restart across the board. That behavior is driven entirely by the exit code, and until now there was no way to change it.

The memory-exceeded exit code has been configurable since PR #57044. The timeout exit code was not, which left this as a gap with no clean workaround short of patching the framework itself.


What Changed

The Worker class now respects a $timeoutExitCode property, consistent with how $memoryExceededExitCode already works. Pass the desired exit code when constructing the worker, and the process will exit with that code on timeout instead of the default.

use Illuminate\Queue\Worker;
use Illuminate\Queue\WorkerOptions;

$worker = app(Worker::class);
$worker->setTimeoutExitCode(0); // or any code your platform treats as non-fatal

If the property is not set, the worker falls back to the existing default, so no existing deployments are affected.


Who Should Care

Any team running Laravel queues on a platform that monitors worker exit codes and triggers pool-wide restarts on repeated timeouts. Setting the timeout exit code to one that the platform ignores, or treats as a clean stop, stops the cascade without requiring any changes to job retry logic or supervisor configuration.

The change follows the same pattern as the memory-exceeded override, so the API will feel familiar if that feature is already in use.

Stay Updated

Subscribe to our newsletter

Get latest news, tutorials, community articles and podcast episodes delivered to your inbox.

Weekly articles
We send a new issue of the newsletter every week on Friday.
No spam
We'll never share your email address and you can opt out at any time.