-
Notifications
You must be signed in to change notification settings - Fork 10.4k
ComponentBase needs proper async error reporting #4964
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
Comments
Note: when implementing this, be sure to update the unit tests in |
Now that Regarding errors happening from IHandleEvent we could change the interface to: Task IHandleEvent.HandleEventAsync(EventHandlerInvoker binding, UIEventArgs args)
{
var task = binding.Invoke(args);
// If there is real async work going on, it adds a call to StateHasChanged() after
// the async work is done
task = ContinueAfterLifecycleTask(task);
// After each event, we synchronously re-render (unless !ShouldRender())
// This just saves the developer the trouble of putting "StateHasChanged();"
// at the end of every event callback.
StateHasChanged();
return task;
} This way errors can flow all the way to the renderer or other component where they can be handled appropriately in a single place. @SteveSandersonMS Thoughts? |
That sounds completely reasonable.
It just so happens that @rynowak was contemplating this last week and started circling around a refinement of the |
@SteveSandersonMS For what is worth I'm in support of my proposal 😄. I think it's better if we handle exceptions in one place and the renderer seems to be the best place for it (as it allows for reporting errors to the appropriate environment). |
* Change event handlers IHandleEvent, IHandleAfterEvent to be async. * Return faulted tasks to Renderer instead of handling exceptions in ComponentBase * Use ILogger in RemoteRenderer, and log to console in WebAssemblyRenderer * Cleaning up touched files Fixes #4964
* Change event handlers IHandleEvent, IHandleAfterEvent to be async. * Return faulted tasks to Renderer instead of handling exceptions in ComponentBase * Use ILogger in RemoteRenderer, and log to console in WebAssemblyRenderer * Cleaning up touched files Fixes #4964
* Change event handlers IHandleEvent, IHandleAfterEvent to be async. * Return faulted tasks to Renderer instead of handling exceptions in ComponentBase * Use ILogger in RemoteRenderer, and log to console in WebAssemblyRenderer * Cleaning up touched files Fixes #4964
* Change event handlers IHandleEvent, IHandleAfterEvent to be async. * Return faulted tasks to Renderer instead of handling exceptions in ComponentBase * Use ILogger in RemoteRenderer, and log to console in WebAssemblyRenderer * Cleaning up touched files Fixes #4964
* Change event handlers IHandleEvent, IHandleAfterEvent to be async. * Return faulted tasks to Renderer instead of handling exceptions in ComponentBase * Use ILogger in RemoteRenderer, and log to console in WebAssemblyRenderer * Cleaning up touched files Fixes #4964
* Improve Components error handling * Change event handlers IHandleEvent, IHandleAfterEvent to be async. * Return faulted tasks to Renderer instead of handling exceptions in ComponentBase * Use ILogger in RemoteRenderer, and log to console in WebAssemblyRenderer * Cleaning up touched files Fixes #4964
Uh oh!
There was an error while loading. Please reload this page.
Currently,
ComponentBase
is hard-coded to deal with async lifecycle exceptions just by logging them to the console. This is understandable (albeit limited) in the WebAssembly case, since the developer console is the only place people are going to look for errors anyway, but it's no good for the server-side execution case.We might want to have an
event
onComponentBase
that reports async lifecycle task failures. Then the WebAssembly host can set up a listener that just logs to console, whereas the server-side executor can wire it into the ASP.NET logging system.The text was updated successfully, but these errors were encountered: