Repository navigation
Fixed circuit disconnects caused by navigation during slow custom CircuitHandler execution - #68633
BrundhaVelusamy wants to merge 41 commits into
Conversation
|
Thanks for your PR, @BrundhaVelusamy. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
…into 59657_CircuitHandler
…samy/aspnetcore into 59657_CircuitHandler
…samy/aspnetcore into 59657_CircuitHandler
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The remaining request for broader Selenium coverage is a non-blocking nit.
Review effort: Lite
Findings: 1
What changed in this PR
Fixes circuit disconnects caused by navigation overtaking delayed circuit-handler execution by serializing root-component update batches per circuit.
Changes:
- Added FIFO batching with disposal and overflow handling.
- Ensured ordered completion and acknowledgements.
- Added unit coverage for ordering and lifecycle behavior.
| File | Summary |
|---|---|
src/Components/Server/test/Circuits/CircuitHostTest.cs |
Adds regression and queue lifecycle coverage. |
src/Components/Server/src/Circuits/CircuitHost.cs |
Implements serialized root-component update processing. |
|
/review |
|
Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime. |
|
/review |
|
The local G/S/O panel completed review of Informational, non-blocking observations Posted for informational purposes so the author can confirm the verifier didn't discard or leave unresolved a real finding; this item does not block
Routine discarded check: No lock cycle or material effect was established for inline callbacks under the update lock at Untested coverage gaps: Actual browser-to-hub overlap and overflow through the real client/hub were not runtime-validated. These are evidence limits, not additional proven defects. Validation boundary: All three local arms reviewed frozen source only; none ran target builds, tests, or browser validation. Hosted Human-directed and GitHub Copilot-generated. |
@PureWeen, Thanks for the additional review. I checked the gate cancellation and E2E synchronization observations. The gate has a bounded wait and is released during cleanup, and the focused managed tests deterministically cover both operation sequencing and removal before initial-render quiescence. I don’t see evidence requiring another production change or additional E2E coverage. |
|
/review |
There was a problem hiding this comment.
🔵 Needs a closer look
A critical concurrency flaw remains in CircuitHost.cs: successor root-component batches can run after an initial lifecycle/render failure because the predecessor barrier is released too early, and no regression test verifies this failure path.
No open issues 🎉
1 resolved since last review
Review effort: Lite
|
Copilot's local review panel found no issues to raise at this commit. G, S, and O completed their independent reviews of Informational, non-blocking checks Posted for informational purposes so the author can confirm the verifier didn't discard or leave unresolved a real finding; this item does not block No candidate verifier was invoked this round because no new provisional finding remained.
Untested coverage gaps: The arms noted no focused tests for later-batch synchronous Add failures or Validation boundary: All three local arms reviewed frozen source only; none ran PR builds, tests, or browser checks. Hosted Human-directed and GitHub Copilot-generated. |
…into 59657_CircuitHandler
…into 59657_CircuitHandler
…samy/aspnetcore into 59657_CircuitHandler
…ndhaVelusamy/aspnetcore into 59657_CircuitHandler" This reverts commit 21140b9, reversing changes made to 665e05a.
…undhaVelusamy/aspnetcore into 59657_CircuitHandler" This reverts commit c490aee.
…b.com/BrundhaVelusamy/aspnetcore into 59657_CircuitHandler"" This reverts commit a709e67.
|
Please keep this focused on the root-component ordering race. The ten-batch limit introduces a new circuit-termination policy beyond the reported bug. Please address that policy separately and keep the bug fix minimal, without leaving queued work unbounded. |
…g while also bounding admission
@kotlarmilos, Thanks for the feedback. Some of the earlier changes were included based on review feedback received from Copilot, GitHub Actions, and PureWeen. I have now updated the commit to keep the fix focused on root-component ordering while also bounding admission. The changes are:
The regression coverage now includes delayed circuit-handler ordering, bounded admission, removal before initial-render quiescence, disposal of queued updates, and acknowledgement after connection cancellation. The focused CircuitHostTest suite passes with 62 tests passed, 0 failed, and 0 skipped. |


Bug Description
When a custom
CircuitHandlerhas latency inOnCircuitOpenedAsync/OnConnectionUpAsync(e.g.,await Task.Delay(...)), navigating to a different page before the handler completes can permanently break the circuit, surfacing to the user as"Circuit has been shut down due to error".Root cause: while the initial
UpdateRootComponentsbatch is suspended awaiting the slow handler, the renderer's dispatcher yields and a second batch — triggered by the navigation — runs concurrently. This second batch can sendUpdate/Removeoperations for SSR component IDs that the first (still in-flight) batch hasn't registered yet, and the existingWebRootComponentManager.UpdateRootComponentAsync/RemoveRootComponentthrowInvalidOperationExceptionfor unregistered IDs. That exception propagates up and firesCircuitHost.UnhandledException, tearing down the circuit even though the client is otherwise healthy.Description of code changes
CircuitHost.csUpdateRootComponentsreserves each incoming batch behind the previously received batch under_rootComponentUpdateLock.UpdateRootComponentsCorewaits for the preceding batch before dispatching the current batch.UpdateRootComponentsOnDispatcher.finally, preventing an unexpected failure from permanently blocking later batches.CancellationToken.None, allowing acknowledgement through the current client connection after reconnection.This prevents navigation batches from overtaking an initial batch delayed by
OnCircuitOpenedAsyncorOnConnectionUpAsync, while preserving every ordered root-component delta.Output
Before changes
59657_BeforeFix.mp4
After changes
59657_AfterFix.mp4
Fixes #59657