Skip to content

Order root-component updates during slow circuit initialization - #145

Closed
PureWeen wants to merge 1 commit into
ccr-components-20261117-circuits-new-basefrom
ccr-components-20261117-circuits-new-head
Closed

PureWeen wants to merge 1 commit into
ccr-components-20261117-circuits-new-basefrom
ccr-components-20261117-circuits-new-head

Conversation

@PureWeen

Copy link
Copy Markdown
Owner

Preserve root-component update ordering while custom circuit handlers initialize.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI max review requested due to automatic review settings November 17, 2026 22:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Root-update ordering can deadlock initialization against disposal, and the fixed queue limit can terminate circuits during ordinary navigation when initialization is slow.

6 open issues
What changed in this PR

This PR adds sequencing for Blazor Server root-component updates to preserve batch dependencies while custom circuit handlers initialize slowly.

Changes:

  • Introduces a bounded update queue with disposal cancellation and overflow reporting.
  • Adds unit coverage for ordering, disposal, queue limits, and acknowledgements.
  • Adds a gated browser scenario for enhanced navigation during circuit initialization.

Validation: Source inspection only; tests and browser scenarios were not run.

File Description
src/​Components/​test/​testassets/​Components.TestServer/​RazorComponentEndpointsStartup.cs Registers the test gate and its endpoints.
src/​Components/​test/​testassets/​Components.TestServer/​CircuitHandlerTestGate.cs Provides controllable circuit-initialization blocking for browser tests.
src/​Components/​test/​E2ETest/​ServerRenderingTests/​InteractivityTest.cs Tests enhanced navigation while initialization is blocked.
src/​Components/​Server/​test/​Circuits/​CircuitHostTest.cs Adds queue ordering, lifecycle, limit, and acknowledgement tests.
src/​Components/​Server/​src/​Circuits/​CircuitHost.cs Implements update sequencing, cancellation, and overflow handling.

Review effort: Max

Comment on lines +784 to +787
if (_pendingRootComponentUpdates >= MaxPendingRootComponentUpdates)
{
// Block updating components if they were provided during StartCircuit. This keeps
// the footprint for Blazor Server closer to what it was before.
throw new InvalidOperationException("UpdateRootComponents is not supported when components have" +
" been provided during circuit start up.");
_rootComponentUpdateQueueOverflowed = true;
reportQueueOverflow = true;
{
try
{
await previousUpdate.WaitAsync(_rootComponentUpdateCancellation.Token);
Comment on lines +814 to +815
UnhandledException?.Invoke(this, new UnhandledExceptionEventArgs(exception, isTerminating: false));
await TryNotifyClientErrorAsync(Client, GetClientErrorMessage(exception), exception);
[LoggerMessage(116, LogLevel.Debug, "The root component operation of type 'Update' was invalid: {Message}", EventName = nameof(InvalidComponentTypeForUpdate))]
public static partial void InvalidComponentTypeForUpdate(ILogger logger, string message);

[LoggerMessage(117, LogLevel.Error, "Circuit '{CircuitId}' exceeded the limit of {MaxPendingRootComponentUpdates} pending root component updates.", EventName = nameof(RootComponentUpdateQueueOverflow))]
})
.ToArray();

await circuitHost.DisposeAsync();
Comment on lines +324 to +326
Browser.Equal("False", () => Browser.FindElement(By.Id("is-interactive-1")).Text);

released = Post($"{ServerPathBase}/circuit-handler-test/release/{token}");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants