[12.x] Add ability to control QueueWorker memory exceeded exit code#57044
Merged
Conversation
|
Thanks for submitting a PR! Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface. Pull requests that are abandoned in draft may be closed due to inactivity. |
tegos
pushed a commit
to tegos/laravel-framework
that referenced
this pull request
Sep 28, 2025
…aravel#57044) * init * Update WorkCommand.php * cs * fix up test * init * Update WorkCommandTest.php * try fix flakiness * cs * Update WorkCommandTest.php * Update WorkCommandTest.php * readd const to prevent breaking change :trollface: * use variable --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
Contributor
|
Hello @jackbayliss For using the new use Illuminate\Queue\Worker;
/**
* Bootstrap any application services.
*/
public function boot(): void
{
Worker::$memoryExceededExitCode = 25;
} |
Contributor
Author
|
@AhmedAlaa4611 Correct :) - or that's at least what I do 🤓 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds the ability to control the memory exceeded exit code.
Any exit code other than 1 is treated as an error. Currently, Laravel uses a hard coded exit code of 12 for memory limits, which can trigger infrastructure-level consequences on some managed hosting platforms.
Real case scenario :
I have many workers running
I can only have so much memory between them
Occasionally - depending on the amount of jobs a worker may hit a memory limit and exit - it's restarted.
The managed hosting provider restarts the whole worker container after 3x errors within 24 hrs (memory limits included) which make all the workers restart, even if they're working through something.
I basically want to force a success if this happens, so I'd use
0as it'll restart as expected, but with no infrastructure consequencesKept the constant in place for backward compatibility (in case anyone extends Worker and relies on it).
Added a test to confirm the static works.
Any thoughts or improvements lmk 🫡