feat(batching): warn/assert on a direct handler shadowing a batch handler (GH-3289 Phase 2)#3301
Merged
jeremydmiller merged 1 commit intoJul 5, 2026
Conversation
…h handler in Classic mode (GH-3289 Phase 2) Phase 2 of the #3289 batch-processing plan (item 6, downscoped to a diagnostic). Under the default MultipleHandlerBehavior.ClassicCombineIntoOneLogicalHandler, a message type that has BOTH a direct Handle(T) handler and a BatchMessagesOf<T>() batch handler silently shadows the batch — the direct handler wins and the batch handler never runs. Separated mode already resolves this legitimately (the batch moves to its own -batch queue); only the Classic case was a silent footgun. - New warnOrAssertBatchHandlerConflicts() runs at startup right after the existing reassignBatchQueuesThatCollideWithHandlers(). In Classic mode, for each batch definition whose element type also has a direct handler chain, it logs a loud warning naming both handlers and pointing at MultipleHandlerBehavior.Separated. - Opt-in WolverineOptions.AssertNoBatchHandlerConflicts() makes it throw at startup instead of warning. - No-ops under Separated mode and when there is no colliding direct handler. Tests cover the default warning (captured via the existing CapturingLogger), the opt-in throw, the batch-only (no conflict) case, and Separated mode staying silent. Docs updated in the "Combining a direct handler with batching" section. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jul 9, 2026
Merged
This was referenced Jul 14, 2026
Open
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.
Phase 2 of the #3289 batch-processing plan — item 6, downscoped to a startup diagnostic. (Phase 0 #3299 merged; Phase 1 is #3300.)
The silent footgun
Under the default
MultipleHandlerBehavior.ClassicCombineIntoOneLogicalHandler, a message type that has both a directHandle(T)handler and aBatchMessagesOf<T>()batch handler silently shadows the batch: the direct handler wins and the batch handler never runs.Separatedmode already resolves this legitimately (the batch is moved to its own-batchqueue and both run) viareassignBatchQueuesThatCollideWithHandlers(). Only the Classic case was silent.Change
warnOrAssertBatchHandlerConflicts()runs at startup right after the existingreassignBatchQueuesThatCollideWithHandlers()inWolverineRuntime.HostService. In Classic mode, for each batch definition whose element type also has a direct handler chain (Handlers.ChainFor(elementType) != null— the batch handler is a separate chain forT[]), it logs a loud warning naming both handlers and pointing atMultipleHandlerBehavior.Separated.opts.AssertNoBatchHandlerConflicts()makes Wolverine throw at startup instead of warning.Separatedmode and when there is no colliding direct handler (the normal batch-only case).Tests
src/Testing/CoreTests/Acceptance/batch_handler_conflict_diagnostic.cs:CapturingLogger), naming both roles + the fix;StartAsyncthrowsInvalidOperationException;Separated+ both handlers → stays silent even when opted in.All 4 green; existing batch acceptance tests unaffected.
dotnet build wolverine.slnx -c Releaseclean.Docs
docs/guide/handlers/batching.md: a warning callout in the "Combining a direct handler with batching" section covering the startup warning and theAssertNoBatchHandlerConflicts()opt-in.🤖 Generated with Claude Code