-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
Break on first-chance exception in Web Assembly debugger #42510
Comments
@TanayParikh if its about breaking when an exception happens, we shouldn't do anything in the framework for it, "Break for first chance exceptions" is a debugger feature. We should make sure that it works in all platforms. |
Yes the issue described in that reddit post is the inability to break on unhandled exceptions. |
Just making sure we aren't talking about two different things. I believe @javiercn is saying the framework doesn't have to automatically support breaking on unhandled exceptions using a first chance mechanism like we see with C# in VS. @jasonswearingen are you perhaps suggesting that it's not possible to manually break on unhandled exceptions at all? In that case, wouldn't a mechanism like |
Perhaps that is the best workaround for the issue, but I prefer not to speculate, as perhaps setting a breakpoint in a global exception handler might destroy state at the callsite that a proper "break on unhandled exception" would preserve. |
This is a functionality of the debugger, if it doesn't work, we shouldn't workaround anything in the framework. We should report it to the right folks to make sure that the experience is fixed. The instructions below are for VS, but applies to VS Code and VS 4 Mac in the same way. |
Thanks for contacting us. |
@javiercn related, do you know if unhandled exceptions are able to be breakpoint triggered in MAUI Blazor WebView? The description of this issue dotnet/maui#4441 imples that it works, but upon closing it is not clear that this is actually working |
@jasonswearingen as far as I know works for both exceptions thrown from JS (if you have the dev tools open and configured to break on thrown JS exceptions) and exceptions thrown from .NET if you have configured the .NET debugger to break on them. |
I've reported it on the VS side here: https://developercommunity.visualstudio.com/t/Blazor-WASM-Debugging-Doesnt-Catch-Unha/10079630 |
@jasonswearingen I'm not sure what you mean by:
Generally speaking, unhandled exceptions aren't automatically caught on MAUI. This is being tracked by dotnet/maui#5535. The first chance exception is raised for Blazor Hybrid apps on WinForms & WPF. |
@lewing FYI |
Tagging subscribers to 'arch-wasm': @lewing Issue DetailsLooks like this is an issue impacting the community: https://www.reddit.com/r/Blazor/comments/vhrrl1/blazor_wasm_how_to_break_on_unhandled_exception/ Ideally we can hook into the Repro:
<button @onclick="ThrowException">Throw Exception</button>
@code {
public void ThrowException()
{
throw new Exception("throwing new ex");
}
}
System.AppDomain.CurrentDomain.UnhandledException += (sender, error) =>
{
System.Console.WriteLine("!!! Encountered exception !!!");
}; Expected: Kind of related: dotnet/maui#5535
|
Tagging subscribers to this area: @thaystg Issue DetailsUpdate: The actual request here is being able to have the debugger break if there's an unhandled exception. Please disregard the stuff about AppDomain.CurrentDomain.UnhandledException. Original reportLooks like this is an issue impacting the community: https://www.reddit.com/r/Blazor/comments/vhrrl1/blazor_wasm_how_to_break_on_unhandled_exception/ Ideally we can hook into the Repro:
<button @onclick="ThrowException">Throw Exception</button>
@code {
public void ThrowException()
{
throw new Exception("throwing new ex");
}
}
System.AppDomain.CurrentDomain.UnhandledException += (sender, error) =>
{
System.Console.WriteLine("!!! Encountered exception !!!");
}; Expected: Kind of related: dotnet/maui#5535
|
Created https://github.com/aspnet/AspNetCore-ManualTests/pull/1451 to add manual testing coverage in this area. @javiercn @SteveSandersonMS should we perhaps be doing something different so that Blazor doesn't catch (or intentionally re-throw) the unhandled exception and so that Currently with |
Turning on all the Javascript exceptions works (All + Uncaught) Though it seems turning these on needs to occur after the app is all started, otherwise there are very many first-chance exceptions caught in the dotnet vm upon startup So at least the method @thaystg described above is a mitigation for the time being. |
Maybe. In The way the logging there works is a bit magical - the implementation comes from some kind of codegen based on a |
@jasonswearingen I would not say @thaystg is a mitigation, it is working as expected. It is unfortunate that the runtime throws many exceptions during boot, however that is a separate problem. For completeness, does it not work for you if you turn on the @SteveSandersonMS I think we might just want to rethrow after we log the exception. That said, we would need to check if that changes the behavior, as I would expect that to crash the app, which if it currently does not, is a big breaking change. I vaguely recall this behavior being "by design", as we didn't care for the exceptions happening on the client (compared to server or now desktop). The reasoning I think it was something like, "an exception happened" but the app is likely to continue working afterwards, so we shouldn't actively prevent it and force a "refresh". |
Thanks for contacting us. We're moving this issue to the |
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
After some further discussion, we think there is no further action to be taken here. We'll monitor this area in the future to see if we need to consider doing more here. But for now - closing this. |
The user experience for debugging exceptions in Blazor WebAssembly apps isn't great. See https://twitter.com/eiriklb1/status/1716871699059388433 for an example of a user complaint about this. Could we maybe do something specifically during development to make the experience better? |
Update: The actual request here is being able to have the debugger break if there's an unhandled exception. Please disregard the stuff about AppDomain.CurrentDomain.UnhandledException.
Original report
Looks like this is an issue impacting the community: https://www.reddit.com/r/Blazor/comments/vhrrl1/blazor_wasm_how_to_break_on_unhandled_exception/
Ideally we can hook into the
System.AppDomain.CurrentDomain.UnhandledException
as we do with WebView for WinForms / WPF.Repro:
Index.razor
:Program.cs
:Expected:
!!! Encountered exception !!!
console outputActual: The exception breaks the world // stack trace dumps to console
Kind of related: dotnet/maui#5535
The text was updated successfully, but these errors were encountered: