Skip to content

Improve circuit initialization error message for failed CircuitHandler dependency resolution - #68078

Merged
ilonatommy merged 2 commits into
dotnet:mainfrom
vendasankarsf3945:feature/circuit-init-error-message
Jul 29, 2026
Merged

ilonatommy merged 2 commits into
dotnet:mainfrom
vendasankarsf3945:feature/circuit-init-error-message

Conversation

@vendasankarsf3945

Copy link
Copy Markdown
Contributor

Improve circuit initialization error message for failed CircuitHandler dependency resolution

Description

When a Blazor Server CircuitHandler cannot be instantiated because of an unresolved dependency, the client only sees a generic Error: The circuit failed to initialize. in the browser console, and the underlying InvalidOperationException is logged on the server at Debug level. This makes the misconfiguration very hard to debug.

This change updates the error message sent to the client in ComponentHub to point developers at the server logs, where the actual exception is already captured. No exception details are sent to the client, and the server log level is unchanged.

Changes

  • Updated the NotifyClientError call in StartCircuit (ComponentHub.cs) to send "The circuit failed to initialize. See the server logs for more information.".
  • Applied the same update to the NotifyClientError call in the circuit resume path (ComponentHub.cs).
  • Left Log.CircuitInitializationFailed and the server log level untouched.
  • No public API changes.

Before

Client console:

Error: The circuit failed to initialize.

After

Client console:

Error: The circuit failed to initialize. See the server logs for more information.

Testing

  • Added StartCircuitFailsWithUnresolvedCircuitHandlerDependency_NotifiesClientToCheckServerLogs in ComponentHubTest.cs to verify the updated client message and that StartCircuit returns null when the circuit factory throws an InvalidOperationException.
  • Added ResumeCircuitFailsWithUnresolvedCircuitHandlerDependency_NotifiesClientToCheckServerLogs to cover the same scenario on the resume path, including the persisted circuit state plumbing.
  • Extended the InitializeComponentHub helper to accept an injectable ICircuitFactory so both tests can supply a failing mock.

Fixes #53300

@vendasankarsf3945
vendasankarsf3945 requested a review from a team as a code owner July 29, 2026 09:26
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Jul 29, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Thanks for your PR, @vendasankarsf3945. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@ilonatommy
ilonatommy enabled auto-merge (squash) July 29, 2026 09:49
@ilonatommy
ilonatommy merged commit f2d72c3 into dotnet:main Jul 29, 2026
33 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-rc1 milestone Jul 30, 2026
@sheiksyedm sheiksyedm added the area-blazor Includes: Blazor, Razor Components label Aug 12, 2026

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — 39930e79 Deployed Jul 29, 2026 by dotnet-policy-service[bot] via pat_pool #741
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-blazor Includes: Blazor, Razor Components community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Poor handling of circuit handlers with unresolved dependencies in Blazor

3 participants