Repository navigation
Conversation
This branch has not been deployed
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.
Description
The
queue:workcommand discarded the outcome of several queue operations, which made failures invisible and could lead to duplicated work.done()— when marking a job as done failed, the worker still printed "The processing of this job was successful" and immediately dispatched the remaining chained jobs. The same job could then be picked up again by another worker while its successors were already queued.later()/failed()— the return values were ignored, so a job that could not be rescheduled or marked as failed left no trace in the logs and stayedRESERVEDforever.push()— a failed push still printed that the chained job "has been placed in the queue", hiding lost chains.catch, which turned an already completed job into a failure and rescheduled it, potentially duplicating the whole chain.Changes
src/Commands/QueueWork.phpdone()succeeded; on failure, log an error and skip dispatching the chained jobs, so a job whose completion is not persisted is not propagated downstream.later()andfailed()and log an error when the handler reports a failure.QueuePushResultreturned when pushing the chained job: log the handler error and print a red warning instead of the success line.processNextJobInChain()intry/catch (Throwable $err)and log the exception, so a chain problem can never mark the already completed job as failed or trigger its retry.$retryAfter ??= $job->getRetryAfter()in the retry branch so the resolved value is used consistently.Testing
Added three cases to
tests/Commands/QueueWorkTest.php:testRunWithChainedJobWhenDoneFailsDoesNotDispatchNextJob()—done()failure is logged, and the chained job is not pushed.testRunWithChainedJobWhenDispatchThrowsExceptionDoesNotFailOrRetryCurrentJob()— an exception from the chained dispatch does not callfailed()/later()for the already processed job.testRunWithChainedJobWhenPushReturnsFailureShowsWarning()— a failed chained push produces the warning message and no success message.Verified locally on PHP 8.5 with PHPUnit 11.5: