-
Couldn't load subscription status.
- Fork 251
Description
When refreshing the page from my diagram i receive the following error:
warn: Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer[100]
Unhandled exception rendering component: JavaScript interop calls cannot be issued at this time. This is because the circuit has disconnected and is being disposed.
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 Blazor.Diagrams.Extensions.JSRuntimeExtensions.UnobserveResizes(IJSRuntime jsRuntime, ElementReference element)
at Blazor.Diagrams.Components.DiagramCanvas.DisposeAsync()
at Microsoft.AspNetCore.Components.RenderTree.Renderer.<>c__DisplayClass85_0.<<Dispose>g__HandleAsyncExceptions|1>d.MoveNext()
Render mode of my application: @rendermode="new InteractiveServerRenderMode(prerender: false)"
I understand that when navigating between pages it's necessary to tidy everything up. However, when the page is refreshed, the circuit is broken. Then, the DisposeAsync() methods of all active components are called. When the DisposeAsync() method of the DiagramCanvas component is called, the JSRuntime (which depends on the already broken circuit) is already marked as disposed.
Therefore shouldn't the code in Blazor.Diagrams.Components.DiagramCanvas.DisposeAsync() be changed to something like this?
try
{
if (elementReference.Id != null)
await JSRuntime.UnobserveResizes(elementReference);
}
catch (JSDisconnectedException)
{
//
}