Fix NoHandlerForEndpointException during concurrent saga chain compile#2556
Merged
jeremydmiller merged 1 commit intoJasperFx:mainfrom Apr 27, 2026
Merged
Conversation
14d0403 to
14bb7b4
Compare
jeremydmiller
added a commit
that referenced
this pull request
Apr 27, 2026
Release v5.33.0 includes: - Fix #2602: leader split-brain via stale Postgres advisory lock (#2607) - Port Polecat 2.x event store integration from Marten (#2598) - Fix #2571: preserve context fields on scheduled-send wrap/unwrap (#2605) - Add launchSettings.json to sample projects (#2600) - gRPC: middleware weaving, validate convention, user exception mapping, bidirectional streaming, code-first codegen, new samples (#2565) - Move non-sticky-handlers guard inside the compile lock (#2556) - Allow RabbitMQ exchanges to be declared passive (#2574) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced Apr 28, 2026
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.
Summary
I ran into this running saga workloads under dynamic codegen. At cold-start, when two messages for the same saga type arrived concurrently, one would sometimes throw
NoHandlerForEndpointExceptioneven though a valid handler was about to be assigned on the other thread. I traced it toHandlerGraph.resolveHandlerFromChain.Root cause
SagaChain.DetermineFramescallsHandlers.Clear()as a side effect of codegen before the generated handler gets registered.resolveHandlerFromChainchecksHasDefaultNonStickyHandlers()outside the compile lock:A concurrent second caller arriving while the first is mid-compile sees the temporarily-empty Handlers,
HasDefaultNonStickyHandlers()returns false, and the throw happens (even though the first thread is about to assignchain.Handler)Note that this is only reproducible under dynamic codegen because pre-generated code doesn't hit this path.
Fix
Move the full "handler present / compile / throw" decision inside
_compilingLock, with a fast-path re-check onchain.Handlerfor threads that arrived after compilation finished.