@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.
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.
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.
1use Illuminate\Queue\Worker;2use Illuminate\Queue\WorkerOptions;3 4$worker = app(Worker::class);5$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.
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.
If you enjoyed this article, please consider supporting our work for as low as $5 / month.
Sponsor
Written by
Writing and maintaining @LaravelMagazine. Host of "The Laravel Magazine Podcast". Pronouns: vi/vim.