-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blazor doesn't DisposeAsync DI scope #12918
Comments
If we do fix this in Blazor instead of DI, we also need to look at other places we create scopes and change to dispose them async. |
My initial feeling is that throwing in |
As part of our sync over async awareness, we need to throw by default and have switches for not throwing. |
What about things that aren't in DI scope? For instance, Controller or Hub instances: https://github.com/aspnet/AspNetCore/blob/master/src/Mvc/Mvc.Core/src/Controllers/DefaultControllerActivator.cs#L72-L75 |
Should have been updated during the 3.x milestone but we missed those places. |
Fixes part of #12918 This fixes the part of this issue that we're going to be able to do in 3.0 safely.
Fixes part of #12918 This fixes the part of this issue that we're going to be able to do in 3.0 safely.
I've made a change for 3.0 to support disposing the scope created by |
Do we have something tracking mvc as well? |
I just #13150 created for it. I don't think it's really time-sensitive that we have this in MVC, it's more about completeness.
|
Blazor doesn't call
DisposeAsync
on the DI scope, which leads to the following exception being logged during Circuit disposal:The DI scope/container is rigid about which kind of disposal you use depending on the services you have. This matrix lays out what happens. Across the top are the kinds of services you have, down the left is how you dispose the scope:
IDisposable
onlyIAsyncDisposable
andIDisposable
IAsyncDisposable
onlyDisposeAsync
Dispose
)DisposeAsync
)DisposeAsync
)Dispose
Dispose
)Dispose
)It's definitely arguable that throwing this exception in DI isn't appropriate. I just want to open the discussion somewhere.
Repro Steps
dotnet new blazorserver
MyScopedDisposableService.cs
:ConfigureServices
:Pages/Index.razor
:Expected Behavior
No error is logged
Actual Behavior
The following error is logged:
The text was updated successfully, but these errors were encountered: