Skip to content

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

@datvm

Description

@datvm

Is there an existing issue for this?

  • 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

<ErrorBoundary>
    <ChildContent>
        <button @onclick="ThrowErr">Throw</button>
    </ChildContent>
    <ErrorContent Context="ex">
        Error: @(ex.Message)
    </ErrorContent>
</ErrorBoundary>

@code {

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

}
  1. Add this component to the BlazorApp1's Home.razor:
@page "/"

<InteractiveApp />
  1. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-blazorIncludes: Blazor, Razor Components

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions