SIGN IN SIGN UP

Fix ObjectDisposedException from ServiceResolver root-provider fallback during requests (#1118)

* fix: don't fall back to the captured root provider in ServiceResolver during a request

When an HTTP request scope is active, `TryResolve` (and its generic/keyed variants)
now resolves solely from `HttpContext.RequestServices` instead of falling back to the
captured root `provider`. The request scope is a child of the root and already sees
every registered service, so the `?? provider` fallback only ever returned null for
unregistered services anyway.

That fallback is unsafe in multi-host processes (e.g. several WebApplicationFactory
instances in a single test run): `UseFastEndpoints()` overwrites the process-global
`ServiceResolver.Instance` and sets `CommandExtensions.TestCommandHandlerMarker`
unconditionally, so command execution (`CommandExtensions.PrepareExecution`) calls
`TryResolve(TestCommandHandlerMarker)`. When the static `Instance` points at a
torn-down host, the marker isn't registered in the live request scope and the fallback
queried that host's disposed root provider -> `ObjectDisposedException: IServiceProvider`.

Adds ServiceResolver regression tests (generic / non-generic / keyed `TryResolve`) that
resolve an unregistered service with an active request scope while the captured root
provider is disposed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* add keyed `ServiceResolver` disposed root regression test

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Dĵ ΝιΓΞΗΛψΚ <dj-nitehawk@users.noreply.github.com>
Co-authored-by: Dĵ ΝιΓΞΗΛψΚ <djnitehawk83@gmail.com>
E
Eugene Barkalov committed
0afb374f52645d6f1dd3f559d323e97d00fa973a
Parent: fbba0ed
Committed by GitHub <noreply@github.com> on 6/5/2026, 6:19:13 AM