-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Closed
Labels
Servicing-considerShiproom approval is required for the issueShiproom approval is required for the issuearea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.
Milestone
Description
Scenario:
- Use Blazor Server
- Add
<NavigationLock ConfirmExternalNavigation="true" />
to any page - Go there, then either do an external navigation and click "Leave" to confirm it, or even just close the browser tab directly
Expected: No exception
Actual: Logs to server console:
fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111]
Unhandled exception in circuit '__YJjLKu09bxilqrSj052d-Jv_H5M5SgQAJWer3i7-0'.
Microsoft.JSInterop.JSDisconnectedException: JavaScript interop calls cannot be issued at this time. This is because the circuit has disconnected and is being disposed.
at Microsoft.AspNetCore.Components.Server.Circuits.RemoteJSRuntime.BeginInvokeJS(Int64 asyncHandle, String identifier, String argsJson, JSCallResultType resultType, Int64 targetInstanceId)
at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, CancellationToken cancellationToken, Object[] args)
at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args)
at Microsoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntime jsRuntime, String identifier, Object[] args)
at Microsoft.AspNetCore.Components.Routing.NavigationLock.System.IAsyncDisposable.DisposeAsync()
at Microsoft.AspNetCore.Components.RenderTree.Renderer.<>c__DisplayClass74_0.<<Dispose>g__HandleAsyncExceptions|1>d.MoveNext()
Reason
Looks like this is simply because we do this JS interop call during DisposeAsync
without catching the JSDisconnectedException
.
Suggested fix
We should wrap that JS invocation in a try { ... } catch (JSDisconnectedException) { /* ignored */ }
.
Metadata
Metadata
Assignees
Labels
Servicing-considerShiproom approval is required for the issueShiproom approval is required for the issuearea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.