Skip to content
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

[Bug] CalculateProgress may result in unhandled exception crashing the application pool #114

Closed
tamjoeho opened this issue Apr 26, 2021 · 1 comment · Fixed by #138
Closed
Labels
Bug Something isn't working

Comments

@tamjoeho
Copy link

tamjoeho commented Apr 26, 2021

Describe the bug
Application crash observed in a production environment.

From Windows Event Viewer:

Application: w3wp.exe
CoreCLR Version: 4.700.20.26901
.NET Core Version: 3.1.5
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ObjectDisposedException: Cannot process pending renders after the renderer has been disposed.
Object name: 'Renderer'.
at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessPendingRender()
at Microsoft.AspNetCore.Components.RenderTree.Renderer.AddToRenderQueue(Int32 componentId, RenderFragment renderFragment)
at Microsoft.AspNetCore.Components.ComponentBase.StateHasChanged()
at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.<>c.b__8_0(Object state)
--- End of stack trace from previous location where exception was thrown ---
at Blazored.Toast.BlazoredToast.CalculateProgress(Int32 percentComplete)
at System.Threading.Tasks.Task.<>c.b__139_1(Object state)
at System.Threading.QueueUserWorkItemCallback.Execute()
at System.Threading.ThreadPoolWorkQueue.Dispatch()

To Reproduce
I haven't personally reproduced it, but it appears that the component being asked to be rerendered has been disposed when CalculateProgress attempts to call StateHasChanged.

Expected behavior
Exception caught and ignored.

Hosting Model (is this issue happening with a certain hosting model?):

  • Blazor Server
@tamjoeho tamjoeho added Bug Something isn't working Triage Issue needs to be triaged labels Apr 26, 2021
@chrissainty chrissainty added the Resolved: Not Enough Info There wasn't enough information provided. label Oct 8, 2021
@tamjoeho
Copy link
Author

tamjoeho commented Oct 8, 2021

I am not sure what additional information is needed.

The failure happens when an Exception occurs when calling the following line in CalculateProgress of BlazoredToast.cs:
await InvokeAsync(StateHasChanged);

This appears to occur when the component creating a toast has its renderer disposed as referenced by the exception provided (e.g. toast is being displayed, user closes the browser tab, component starts to be disposed, and then CalculateProgress is called). Crashing the application can be simulated by adding an Exception in CalculateProgress. To reproduce this normally, one would have to be able to guarantee that the renderer for the component is disposed prior to the CalculateProgress method being called and possibly before some other part of the component from being disposed which might prevent the method from being called at all (i.e. I am not sure if the Timer used will be disposed at some point as well or if it always gets to invoke the callback).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants