dotnet / dotnet/aspnetcore

ErrorBoundary does not work for Blazor Web App even inside InteractiveWebAssembly with no prerendering

Open
#63,518 0 comments 0 reactions 0 assignees View on GitHub
area-blazor
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Describe the bug

This is similar to #56413 but that issue appear to be for Server Interactive or cross-boundary components. However, this issue also happen when the component is fully client-side (InteractiveWebAssembly, including with pre-rendering set to false).

### Expected Behavior

ErrorBoundary should prevent exceptions to go up and show `ErrorContent` instead.

### Steps To Reproduce

1. Create a new project using Blazor Web App template, choose WebAssembly interactive and Per Page/Component mode.
2. In `BlazorApp1.Client`, create a compoent like `InteractiveApp.razor`:

```
@rendermode InteractiveWebAssembly


Throw


Error: @(ex.Message)

@code {

void ThrowErr() => throw new InvalidOperationException("An error occurred.");

}
```

3. Add this component to the BlazorApp1's `Home.razor`:

```
@page "/"

```

4. Run the app and click the Throw button.

### Exceptions (if any)

The thrown exception go up and cause the bottom bar to show up instead of being handled by the ErrorBoundary.

### .NET Version

_No response_

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.