Skip to content

Backport #52687 to .NET8 #55892

Open
Open
@ScarletKuro

Description

@ScarletKuro

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Hi,

Please backport fix #52687 to .NET 8.

Some MudBlazor customers report (MudBlazor/MudBlazor#7879) that they get exceptions when using:

app.UseExceptionHandler("/Error", createScopeForErrors: true);

or when they use Azure (MudBlazor/MudBlazor#8850).

The main problem is that our services added to the DI are implementing only IAsyncDisposable. We find this justified as we need to use some async code during disposal, and you can't use GetAwaiter().GetResult() in Blazor WASM. We also don't think that fire-and-forget is a good practice either.

I find that it's a bug in .NET 8 that it's calling CreateScope instead of CreateAsyncScope. Since it was fixed for .NET 9, it should be ported to .NET 8 as it's still supported. I don't see any breaking change risks here nor it doesn't require any new API.

Thank you.

Expected Behavior

Not to throw exception.

Steps To Reproduce

No response

Exceptions (if any)

System.InvalidOperationException: 'MudBlazor.BrowserViewportService' type only implements IAsyncDisposable. Use DisposeAsync to dispose the container.
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.Dispose()
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.HandleException(HttpContext context, ExceptionDispatchInfo edi)

.NET Version

No response

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-middlewareIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewaresfeature-diagnosticsDiagnostic middleware and pages (except EF diagnostics)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions