Batching honors a batch handler registered with AddMessageHandler - #4623
Open
jeremydmiller wants to merge 1 commit into
Open
jeremydmiller wants to merge 1 commit into
jeremydmiller wants to merge 1 commit into
Conversation
BatchingOptions' processor builder and the batch probe policy both looked the
batch type up with HandlerGraph.ChainFor, which reads discovered chains only.
A batch handler registered with AddMessageHandler -- a pre-generated or
hand-written MessageHandler -- was therefore refused on the first element
("no known handler for T[]", every element to the error queue), and a
ProbeIndividuallyAfter policy was skipped for it without a word.
Both now go through HandlerGraph.ChainOrRegisteredHandlerChainFor, which falls
back to the registered handler's own chain. The error also names the batch type
the batcher actually produces instead of assuming T[].
Found by CritterWatch (JasperFx/CritterWatch#1356), whose embedded console
registers pre-generated handlers so its host needs no runtime compilation.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Batching honors a batch handler registered with AddMessageHandler
Problem
BatchMessagesOf<T>()refused a batch handler registered withopts.AddMessageHandler(typeof(TBatch), handler)— a pre-generated or hand-writtenMessageHandler. Two places looked the batch type up withHandlerGraph.ChainFor, which reads discovered chains only:BatchingOptions.ProcessorBuilder<T>.Buildthrew on the first element — "…there is no known handler for T[]" — so every element went to the error queue. The message also namedT[]even when a customIMessageBatcherproduces a different batch type.WolverineRuntime.applyBatchProbePoliciesskippedProbeIndividuallyAfter(n)for such a handler without a word.Found by CritterWatch (JasperFx/CritterWatch#1356): its embedded console now registers pre-generated handler classes with
AddMessageHandler, so an embedding host needs no runtime compilation. The console batches its telemetry, and the console received nothing.Fix
HandlerGraph.ChainOrRegisteredHandlerChainFor(Type)(internal): the discovered chain, else the chain of aMessageHandlerin the pre-canned map. It reads the map directly rather than throughHandlerFor, so a miss is not memoized and anIAgentCommandtype does not take the agent path. Both call sites use it. The error namesbatcher.BatchMessageType.Tests
CoreTests.Acceptance.batching_with_a_registered_batch_handler— the element type is batched onto the registered handler's chain, the probe policy reaches that chain, and batches are delivered end to end. All three fail without the fix (verified by revertingsrc/Wolverine) and pass with it. All 345 batching/pre-canned tests and the full CoreTests suite (3,111 passed, 2 skipped, 0 failed, net9.0) are green.Also verified downstream: CritterWatch packed against a local
6.40.1-cw1356.1— its embedded console lists its own host within a second, where it never did on 6.40.0.🤖 Generated with Claude Code