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

MudBlazor template is missing unhandled exceptions div #9020

Open
1 of 2 tasks
d00lar opened this issue May 20, 2024 · 7 comments
Open
1 of 2 tasks

MudBlazor template is missing unhandled exceptions div #9020

d00lar opened this issue May 20, 2024 · 7 comments

Comments

@d00lar
Copy link

d00lar commented May 20, 2024

Bug type

Component, Other

Component name

MainLayout

What happened?

in default MudBlazor serwerside template
in routes.razor / old index.html

You guys are missing

<div id="blazor-error-ui"> <span style="color:black">An unhandled error has occurred.</span> <a href="" class="reload">Reload</a> <a class="dismiss">🗙</a> </div>

without this when there is an unhandled expeption

for example
if in famus 'counter' component page we change from

private void IncrementCount()
{
    currentCount++;
}

to

private async Task IncrementCount()
{
      currentCount++;
      throw new Exception("test");
}

then onclick there is no exception throwed in VS
and app just freeze.

BE AWARE
IN TRY MUDBLAZOR LINK everything is ok
in default New Project / MudBlazor template NO.

Expected behavior

in defualt template error handling 'down bar' should be also implemented

Reproduction link

https://try.mudblazor.com/snippet/mEGIaTGkGgKtdJXD
https://stackoverflow.com/questions/78493661/blazor-serverside-why-is-exception-not-thrown-when-in-task-how-to-avoid-this

Reproduction steps

  1. new serverside project from mudblazor templates
  2. change counter page code to as i wrote above
  3. vlick on counter btn.
    ...

Relevant log output

No response

Version (bug)

6.19

Version (working)

No response

What browsers are you seeing the problem on?

Chrome

On which operating systems are you experiencing the issue?

Windows

Pull Request

  • I would like to do a Pull Request

Code of Conduct

  • I agree to follow this project's Code of Conduct
@MBNSoftware
Copy link

Hello,

Could this "help" ?

https://medium.com/@alexandre.malavasi/why-exceptions-in-async-methods-are-dangerous-in-c-fda7d382b0ff

To summarize, it's mainly because the Task is not (may not be) awaited. Which is potentially understandable if the original method was not a task : the calls to it were not "awaited".

So I would not qualify this as a bug but rather as a bad programming practice (no offence to you, of course).

Regards,
Christophe

@d00lar
Copy link
Author

d00lar commented May 20, 2024

Yes i known all that
but best practise is best practise
and life is life / sometimes someone can forget something
but still
in default .net template
there is some 'bar' at the bottom of page with reload btn as You probably known
so same thing im expecting in mudblazor template?
in .net6 template of mudblazor WebAssembly it was
but in .net 8 template for 'server side' project there is not - this DIV is missing
with this as i wrote

An unhandled error has occurred. Reload 🗙

this is as expected - do You think it should not be there anymore?
regards

@MBNSoftware
Copy link

To be honest, as I feel it's a "bad programming practice", I would not even try to solve this. It would add mess where there's already enough, I think.

Don't get me wrong, though, I understand your need to handle such exception in a task. But, as many sources seem to agree, the correct way to handle it properly is to await the call. Period.
I'm not skilled enough to go against that, hence my advice to (try to) stay with good practice. Again, no offence but pure common sense or pragmatism,

Regards,
Christophe

@d00lar
Copy link
Author

d00lar commented May 22, 2024

so You guys think that default blazor option for handling unhandled exceptions - 'Down bar showing that some error occured and You can try reload'
is not needed anymore? but it was needes sometimes ago..? in mudblazor older / webassembly template? from witch version this concept is abbanden?

@Anu6is
Copy link
Contributor

Anu6is commented May 22, 2024

I think you guys are discussing two different things.
@MBNSoftware is addressing how to address the specific exception scenario you gave as an example. While @d00lar is simply saying that the basic unhandled exception catch all logic is missing from the template. The issue raised has nothing to do with awaiting a task or not but what happens when an unhandled exception occurs.

The issue was also brought up on the template repo MudBlazor/Templates#451

@d00lar
Copy link
Author

d00lar commented May 22, 2024

exacly - it is just example nothing more.
also it just 'freaze app' when this div is missing so if some unaware developer will hit this kind of error - he can wait even hour or two waiting for task to compleat seeing no error or no sign of something bad happened.

@jperson2000
Copy link
Sponsor Contributor

Hi everyone, as part of upgrading templates for the upcoming MudBlazor 7.0.0 release, I rebuilt templates from scratch and the error <div> is there. You can find the change in this PR: MudBlazor/Templates#465

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants