Repository navigation
[Mocha] Fix acknowledgements of saga commands without a response landing in the skipped queue - #11051
Merged
PascalSenn merged 2 commits intoNov 23, 2026
Merged
Conversation
…ing in the skipped queue A saga with a reply transition receives the replies to its commands on its own endpoint. A command handled by an `IEventRequestHandler<T>` without a response is acknowledged with an `AcknowledgedEvent`, which no route of the saga selected unless the saga declared a transition for it, so every such acknowledgement was moved to the saga's skipped queue. The saga consumer now adds a saga-id gated reply route for `AcknowledgedEvent` when the saga has a reply transition and none of them selects acknowledgements. The saga discards an acknowledgement with a debug log entry when no transition of its current state handles it, or when the saga has ended. Other replies that no transition handles still go to the skipped queue.
Contributor
Patch coverage100.0% of changed lines covered (38/38)
Project coverage: 60.1% (330776/550329 lines) |
PascalSenn
marked this pull request as ready for review
November 23, 2026 16:18
PascalSenn
deleted the
ps/mocha-saga-discard-unhandled-acknowledgements
branch
November 23, 2026 16:18
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.
Follow-up to #11022.
Problem
Since #11022, the replies to a saga's commands go to the saga's queue, and a reply that no transition handles moves to the saga's skipped queue. A command handled by an
IEventRequestHandler<T>without a response is acknowledged with anAcknowledgedEventto the reply address the saga stamped. No route of the saga selected that acknowledgement unless the saga declared a transition for it, so every such command left oneAcknowledgedEventin{service}.{saga}_skipped.A saga could not opt out with one declaration. A transition must name a target state, so there is no "accept
AcknowledgedEventin any state and stay there", and an acknowledgement that arrives after the saga ended has no state at all.Change
SagaConsumeradds a saga-id gated reply route forAcknowledgedEventwhen the saga has a reply transition and none of its reply transitions already selects acknowledgements (OnAnyReply,OnReply<AcknowledgedEvent>). The route binds to the saga's existing reply endpoint.Saga<TState>.HandleEventdiscards anAcknowledgedEventwith a debug log entry when no transition of the current state handles it. The state is not changed, not re-entered and not saved.AcknowledgedEventfor a saga that has ended is consumed with a debug log entry.OnHandleTransitionAsyncmoves to a privateFindTransitionhelper that both paths use.The alternative, stamping a reply address only on messages with a response type, would break sagas that wait for the acknowledgement of a command with
OnAnyReply(Saga_Should_ReceiveAcknowledgement_When_CommandWithoutResponseSucceeds).Behavior changes
OnAnyReply, is discarded. Before, it threwSagaExecutionException.Tests
Saga_Should_MoveReplyToSkippedQueue_When_NoReplyTransitionMatches(Postgres) asserted the acknowledgement in the skipped queue. It now uses a typed reply that no transition handles.