Skip to content

[Messenger] Remove fix NoAutoAckStamp handling in Worker::flush() #61291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 5, 2025

Conversation

wazum
Copy link
Contributor

@wazum wazum commented Jul 31, 2025

Q A
Branch? 6.4
Bug fix? yes
New feature? no
Deprecations? no
Issues -
License MIT

Description

This PR removes unused code in the Worker::flush() method where an envelope modification was never used.

Changes

  • Removed the line $envelope = $envelope->withoutAll(NoAutoAckStamp::class); which was modifying a local variable that was immediately discarded
  • Moved the NoAutoAckStamp removal to the catch block where it's actually needed

Why this change?

The line was unused code because:

  1. If dispatch() succeeds: The modified envelope is never used (foreach continues/ends)
  2. If dispatch() throws: The line is never reached

Moving the stamp removal to the catch block ensures that envelopes stored for acknowledgment have clean state - they shouldn't contain a "no auto ack" stamp when they're about to be acknowledged.

@carsonbot carsonbot added this to the 6.4 milestone Jul 31, 2025
@carsonbot carsonbot changed the title [Messenger] Remove dead code in Worker::flush() method [Messenger] Remove unused code in Worker::flush() method Jul 31, 2025
@OskarStark OskarStark changed the title [Messenger] Remove unused code in Worker::flush() method [Messenger] Remove unused code in Worker::flush() method Aug 1, 2025
@OskarStark
Copy link
Contributor

This PR not only removes unused code, but changes code. Can you please add or modify an existing test case? Thanks

@wazum wazum force-pushed the bugfix/messenger-flush-dead-code branch from 1d1766d to bb580f1 Compare August 1, 2025 07:18
@wazum wazum changed the title [Messenger] Remove unused code in Worker::flush() method [Messenger] Remove dead code and fix NoAutoAckStamp handling in Worker::flush() Aug 1, 2025
@carsonbot carsonbot changed the title [Messenger] Remove dead code and fix NoAutoAckStamp handling in Worker::flush() [Messenger] Remove unused code and fix NoAutoAckStamp handling in Worker::flush() Aug 1, 2025
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix does make sense to me.
Ideally the test case shouldn't use reflection to hack into internal structures.
Would it be possible to use only public methods instead?

@nicolas-grekas nicolas-grekas changed the title [Messenger] Remove unused code and fix NoAutoAckStamp handling in Worker::flush() [Messenger] Remove fix NoAutoAckStamp handling in Worker::flush() Aug 1, 2025
@wazum wazum force-pushed the bugfix/messenger-flush-dead-code branch from bb580f1 to 1d3caf6 Compare August 1, 2025 16:05
@wazum
Copy link
Contributor Author

wazum commented Aug 1, 2025

That's the best I could come up with. Using only minimal Reflection to fill the unacks property.
Previous attempts using the natural flow resulted in "The acknowledger was not called by the batch handler" fatal errors. I couldn't solve this otherwise.

The line `$envelope = $envelope->withoutAll(NoAutoAckStamp::class);` was modifying a local variable that was never used after assignment. This change moves the stamp removal to the catch block where it's actually needed, ensuring envelopes stored for acknowledgment don't contain contradictory NoAutoAckStamp.
@wazum wazum force-pushed the bugfix/messenger-flush-dead-code branch from 1d3caf6 to 06b1d8f Compare August 1, 2025 16:13
@nicolas-grekas
Copy link
Member

Thank you @wazum.

@nicolas-grekas nicolas-grekas merged commit 9aa072c into symfony:6.4 Aug 5, 2025
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy