Repository navigation
[Blazor Hybrid] Guard HandleComponentException after renderer disposal - #70304
Conversation
|
Thanks for your PR, @irfanajaffer. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
There was a problem hiding this comment.
🔵 Needs a closer look
Independent review checks cannot be completed because the required frozen head/merge-base/base-tip bundle and existing-feedback snapshot are unavailable.
No open issues 🎉
What changed in this PR
Addresses #66322 by ignoring late component exception dispatches once renderer disposal has begun, preventing missing-component failures reported in Blazor Hybrid.
Changes:
- Adds a disposal guard before component-state lookup and exception routing.
- Adds regression tests for completed and pending disposal, dispatcher ordering, component removal, and unchanged exception routing for live components.
| File | Description |
|---|---|
src/Components/Components/test/RendererTest.cs |
Adds disposal and exception-routing regression coverage. |
src/Components/Components/src/RenderTree/Renderer.cs |
Returns early from HandleComponentException when the renderer is disposed. |
Review effort: Balanced
|
/review |
|
Copilot's local review panel found no issues to raise at this commit. |
kotlarmilos
left a comment
There was a problem hiding this comment.
LGTM! Please reduce the testing coverage
|
Addressed. I reduced the test coverage to focus only on the scenarios directly validating the fix, removing the broader coverage that was not required for this change. The remaining tests verify the intended behavior while keeping the test impact minimal and aligned with the scope of the fix. |
|
@irfanajaffer Please take a look at the failing CI |
|
✅ No documentation PR was created. Confidence that documentation is needed: 8% No docs needed: a bug-fix guard against exception dispatch after renderer disposal, with tests only. Documentation surfaces considered
|
Description
Added a disposal guard in
Renderer.HandleComponentExceptionto prevent exception routing after the renderer has already been disposed.The reported scenario involves
DispatchExceptionAsyncbeing invoked after component or renderer teardown in Blazor Hybrid applications. Previously,HandleComponentExceptioncould attempt to resolve component state after disposal, leading to failures when the renderer no longer contained the target component. This change ensures such late exception dispatches are safely ignored once renderer disposal has begun or completed.Changes Made
_rendererIsDisposedguard inRenderer.HandleComponentException.Testing
Added/updated unit tests covering:
DispatchExceptionAsyncafter renderer disposal does not throw.DispatchExceptionAsyncduring renderer disposal does not throw.DispatchExceptionAsyncwhile async disposal is pending does not throw.Before and After Fix Evidences
After.Fix.mp4
Issue
Fixes #66322