Repository navigation
Bump JasperFx 2.3.0: fix HTTP codegen-write service location (GH-2991) - #2993
Merged
Merged
Conversation
…on (GH-2991) JasperFx 2.3.0 (#401) makes the `codegen write` / preview path honor WolverineHttpOptions.ServiceProviderSource, matching the runtime. Previously a service-located dependency (an opaque scoped lambda factory) was generated against an isolated serviceScope under `codegen write` even when the app configured FromHttpContextRequestServices, so the pre-generated code differed from (and was wrong vs.) the runtime-generated code — yielding two different scoped instances for one request. Carries the reproduction from #2992 (EfCoreEndpoints /ef/servicelocation + http_handler_with_http_context_sourced_gets_the_same_service). That test exercises the runtime path (which was always correct); the codegen-write regression itself is guarded by the new DynamicCodeBuilder test in #401. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 1, 2026
This was referenced Jul 13, 2026
This was referenced Jul 20, 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.
Closes #2991. Supersedes #2992 (carries its reproduction, with @PerChr's authorship preserved).
Problem
With
WolverineHttpOptions.ServiceProviderSource = FromHttpContextRequestServices, the runtime generated correct code (service-located deps fromhttpContext.RequestServices), butdotnet run -- codegen writegenerated different and wrong code: an opaque scoped lambda-factory dependency was service-located from an isolatedserviceScopewhile a siblingDbContextusedhttpContext.RequestServices→ two different scoped instances for one logical request.Root cause + fix (JasperFx)
The CLI codegen paths (
DynamicCodeBuilder) never applied the per-fileTryReplaceServiceProvider/ReplaceServiceProviderstep that the runtimeDynamicTypeLoaderdoes. Fixed in jasperfx#401 → JasperFx 2.3.0, including a newIServiceVariableSource.ResetServiceProvider()so the override is isolated per file on the CLI's shared source (otherwise it would leakhttpContext.RequestServicesinto every following file). That PR carries the preciseDynamicCodeBuilderregression test.This PR
EfCoreEndpoints/ef/servicelocation+http_handler_with_http_context_sourced_gets_the_same_service). Note: that test exercises the runtime path, which was always correct, so it passes pre- and post-fix — it documents the scenario and guards against a runtime regression; the codegen-write defect itself is guarded by the JasperFx test.Verification
WolverineWebApiwith 2.3.0 viacodegen writenow resolves the opaque scoped service and theDbContextboth fromhttpContext.RequestServices, with no leak ofhttpContext.RequestServicesinto non-HTTPMessageHandlerfiles.using_efcoresuite green on 2.3.0.🤖 Generated with Claude Code