fix: support colored output from queue:listen #52223
Closed
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.
Currently laravel queue jobs do not have colored output when they are run by the artisan queue listener
php artisan queue:listen --tries=1 --timeout=1800
,php artisan queue:work --once
works just fine.This is due to a symfony change in their dedection algorithm which I think was buggy in the past and returned true incorrectly (if their algorithm is actually wrong again and this is an upstream issue then feel free to close this one). reference: https://github.com/symfony/symfony/blob/7.2/src/Symfony/Component/Console/Output/StreamOutput.php
For subprocess which we are spawning I believe the correct way of handling things is by enabling the tty feature of the process via
setTty(true)
like someone else described here symfony/symfony#23002.Enabling this however leads to regressions, since #44971 the queue listener will only print "Processing jobs from the [] queue" once, this done via
Terminal::hasSttyAvailable()
.The change in enabling the tty again is breaking this detection and as such we need a different way to detect if we need to print the message again, this is handled by the
isChildProcess
function. If you have better ideas on how to solve this I'm happy to change this part.