Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix empty render of the ErrorBoundary#64526

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
dariatiurina wants to merge2 commits intodotnet:main
base:main
Choose a base branch
Loading
fromdariatiurina:56950-error-boundary

Conversation

@dariatiurina
Copy link
Contributor

Fix empty render of the ErrorBoundary

Description

This PR fixes a bug where ErrorBoundary renders empty content instead of ErrorContent when multiple child components throw errors in quick succession (e.g., errors thrown inside a foreach loop like in the test example).

How it works normally (single error):

The Renderer queues an empty render to clear the subtree, then callsHandleException, which queues the ErrorContent render. This works correctly.

The bug (multiple errors):

When a second error is thrown:

  1. Renderer queues another empty render - this sets_hasPendingQueuedRender = true
  2. Renderer callsHandleException to queue the ErrorContent render
  3. StateHasChanged() returns early because_hasPendingQueuedRender is stilltrue from step 1
  4. The ErrorContent render is never queued

The queue ends up with:[empty, ErrorContent, empty] instead of[empty, ErrorContent, empty, ErrorContent]. After the first ErrorContent renders, only the empty render remains in the queue, clearing the error UI.

Solution:

After queuing the empty render but before callingHandleException, manually reset_hasPendingQueuedRender tofalse using the new internalHasPendingQueuedRender property. This ensuresStateHasChanged() successfully queues the ErrorContent render for each error.

Fixes#56950

@github-actionsgithub-actionsbot added the area-blazorIncludes: Blazor, Razor Components labelNov 25, 2025
@dariatiurinadariatiurina self-assigned thisNov 25, 2025
/// <summary>
/// Gets or sets a value that indicates whether there is a pending queued render.
/// </summary>
internalboolHasPendingQueuedRender
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Is there a way how we could implemement this fix forErrorBoundary components without reducing encapsulation for every component? E.g. by overridingStateHasChanged forErrorBoundary.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@oroztociloroztociloroztocil left review comments

Copilot code reviewCopilotAwaiting requested review from CopilotCopilot will automatically review once the pull request is marked ready for review

At least 1 approving review is required to merge this pull request.

Assignees

@dariatiurinadariatiurina

Labels

area-blazorIncludes: Blazor, Razor Components

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Blazor ErrorBoundary error content not shown when exception occurs inside @foreach

2 participants

@dariatiurina@oroztocil

[8]ページ先頭

©2009-2025 Movatter.jp