Repository navigation
Fix #346: Document and test the loop check before processing a message - #349
Merged
Merged
Conversation
`queue:run --limit=1` over two queued messages reported one processed and left the queue empty: `InMemoryAdapter::runExisting()` removed the message that tripped the limit even though the callback returned `false` without handling it. Both shipped adapters already treat `false` as "not consumed" — `queue-redis` deletes only when the callback returned `true`, `queue-amqp` nacks with requeue otherwise — so the stub was the outlier. Spell that contract out on `runExisting()` and `subscribe()`.
This was referenced Oct 28, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #349 +/- ##
============================================
+ Coverage 94.59% 94.90% +0.30%
Complexity 375 375
============================================
Files 59 59
Lines 981 981
============================================
+ Hits 928 931 +3
+ Misses 53 50 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
KalimeroMK
reviewed
Oct 28, 2026
…essage-on-stop # Conflicts: # src/Adapter/AdapterInterface.php # src/QueueConsumer.php # tests/Unit/QueueTest.php
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.
Fixes #346.
The handler callback that
QueueConsumerpasses to adapters used to return$this->loop->canContinue()after processing the message. So when the loop stopped (for example, onSIGTERM), the callback returnedfalsefor a message that was already handled, and adapters, which treatfalseas "not processed", kept it and handled it again.#340 moved the loop check before processing in both
QueueConsumer::run()andQueueConsumer::listen(), sofalsenow always means "not processed, stop". This completes the fix:listen()is covered: a message processed just before the loop stops is done, and the next one is left waiting.Adapters must not acknowledge a message when the callback returns
false. The AMQP adapter's matching change, yiisoft/queue-amqp#143, should be merged together with this one. yiisoft/queue-db#35 relies on the same meaning offalseand should be merged after this one.