-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
Describe the bug
An exception is thrown during the Dispose handler of the IntersectionObserve component when the circuit itself is being disposed.
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 Ljbc1994.Blazor.IntersectionObserver.IntersectionObserverService.RemoveObserver(String id)
at Ljbc1994.Blazor.IntersectionObserver.IntersectionObserver.Dispose()
at Ljbc1994.Blazor.IntersectionObserver.Components.IntersectionObserve.DisposeAsync()
at Microsoft.AspNetCore.Components.RenderTree.Renderer.<>c__DisplayClass69_0.<<Dispose>g__HandleAsyncExceptions|1>d.MoveNext()
Everything still works fine after the exception, but it fills up the error log with unnecessary error messages.
To Reproduce
- Create a page that contains the IntersectionObserve component
- Refresh or close the page
- An exception will be logged to the error logs
Expected behavior
Catch and silently ignore the exception since we don't need to dispose of the observer if the browser is being closed anyway.
System Info
- Blazor Server
- .NET 6
Additional context
This was caused by a changed to Blazor that prevents JS Interop actions during circuit disposal: dotnet/aspnetcore#32901
derekoakley and MrCliff
Metadata
Metadata
Assignees
Labels
No labels