Skip to content

Fix reconnect UI stuck after ConnectCircuit/ResumeCircuit failure - #70112

Open
vendasankarsf3945 wants to merge 10 commits into
dotnet:mainfrom
vendasankarsf3945:fix-reconnect-ui-stuck
Open

vendasankarsf3945 wants to merge 10 commits into
dotnet:mainfrom
vendasankarsf3945:fix-reconnect-ui-stuck

Conversation

@vendasankarsf3945

@vendasankarsf3945 vendasankarsf3945 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Fix reconnect UI stuck after ConnectCircuit/ResumeCircuit failure

Description

This PR fixes an issue where the reconnect UI becomes stuck when ConnectCircuit or ResumeCircuit hub method invocations fail, leaving the Blazor client in an unresponsive state.

Root Cause

When the ConnectCircuit or ResumeCircuit hub method invocations fail (throw an exception), the SignalR connection is not properly cleaned up. The circuit manager leaves the connection in a "Connected" state even though the circuit operation failed, resulting in:

  1. The connection object remaining open but in an inconsistent state
  2. The UI being stuck in a reconnecting/loading state
  3. Subsequent reconnection attempts failing because the old connection was never properly terminated
  4. The client unable to recover without a manual page refresh

The root cause is the lack of error handling around these critical hub method invocations. Previously, if ConnectCircuit or ResumeCircuit threw an exception, the code would immediately propagate the error without stopping the underlying connection, leaving it orphaned.

Changes Made:

  1. CircuitManager.ts:

    • Added try-catch wrapper around ConnectCircuit invocation to catch errors and stop the connection before re-throwing
    • Added try-catch wrapper around ResumeCircuit invocation with the same error handling
    • Created stopConnectionAfterFailedCircuitInvocation() private method to safely stop the connection and log any errors that occur during cleanup
  2. CircuitManagerReconnect.test.ts (new file):

    • Added comprehensive tests verifying that the connection is stopped when ConnectCircuit throws
    • Added tests verifying that the connection is stopped when ResumeCircuit throws
    • Added tests ensuring that callback handlers (onCircuitClosed, onCircuitOpened) throwing errors do not trigger the automatic connection stop behavior

Technical Details:

  • When ConnectCircuit or ResumeCircuit fail, the error is now caught, the connection is stopped, and the error is re-thrown for higher-level handling
  • The stopConnectionAfterFailedCircuitInvocation() method handles any errors that occur during the connection stop operation itself, logging them as errors
  • This ensures the client is not left in a stuck state when circuit operations fail

Testing

PASS test/Platform/Circuits/CircuitManagerReconnect.test.ts
CircuitManager reconnect
✓ stops the connection when ConnectCircuit throws (XX ms)
✓ stops the connection when ResumeCircuit throws (XX ms)
✓ does not stop the connection when onCircuitClosed throws (XX ms)
✓ does not stop the connection when onCircuitOpened throws (XX ms)

image

Fixes #69931

@github-actions github-actions Bot added the area-blazor Includes: Blazor, Razor Components label Oct 30, 2026
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Oct 30, 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.

@vendasankarsf3945
vendasankarsf3945 marked this pull request as ready for review November 3, 2026 11:24
@vendasankarsf3945
vendasankarsf3945 requested a review from a team as a code owner November 3, 2026 11:24
Copilot AI balanced review requested due to automatic review settings November 3, 2026 11:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported for the Blazor circuit reconnection and cleanup changes.

No open issues 🎉

What changed in this PR

This PR addresses #69931 by cleaning up failed Blazor circuit connections so subsequent reconnect attempts can proceed instead of leaving the reconnect UI stuck.

Changes:

  • Stops and awaits connection cleanup when ConnectCircuit or ResumeCircuit throws, then rethrows the original error.
  • Coalesces overlapping reconnect attempts, guards renderer detachment, and delays resume completion until circuit-open callbacks finish.
  • Adds unit tests covering invocation failures, overlapping reconnects, callback errors, and connection closure with detached renderer interop.
File Description
src/​Components/​Web.JS/​test/​Platform/​Circuits/​CircuitManagerReconnect.test.ts Adds focused reconnect and resume lifecycle tests.
src/​Components/​Web.JS/​src/​Platform/​Circuits/​CircuitManager.ts Adds failed-invocation cleanup and coordinates reconnect and resume lifecycle handling.

Review effort: Balanced

@PureWeen

PureWeen commented Nov 3, 2026

Copy link
Copy Markdown
Member

/review

@PureWeen

PureWeen commented Nov 4, 2026

Copy link
Copy Markdown
Member

/review

@PureWeen

PureWeen commented Nov 4, 2026

Copy link
Copy Markdown
Member

Copilot's local review panel found no issues to raise at this commit.

@kotlarmilos
kotlarmilos self-requested a review November 6, 2026 14:58

@kotlarmilos kotlarmilos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Changes look good. Please reduce the test scaffolding and consolidate JS coverage

@vendasankarsf3945

Copy link
Copy Markdown
Contributor Author

Changes look good. Please reduce the test scaffolding and consolidate JS coverage

Thanks for the feedback. I've reduced the test scaffolding and consolidated the existing JS coverage to eliminate duplication and improve readability.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime.
To make sure no conflicting changes have occurred, please rerun validation before merging. You can do this by leaving an /azp run comment here (requires commit rights), or by simply closing and reopening.

@dotnet-policy-service dotnet-policy-service Bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Nov 17, 2026

This branch was previously deployed

1 inactive (outdated) deployment
copilot-pat-pool — e2e90ceb Deployed Oct 30, 2026 by dotnet-policy-service[bot] via pat_pool #2035
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-reviewed-approved area-blazor Includes: Blazor, Razor Components community-contribution Indicates that the PR has been added by a community member pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Blazor] Reconnect UI stuck for good (no further attempts, no Retry) after an attempt whose ConnectCircuit or ResumeCircuit invocation throws

6 participants