Skip to content

Conversation

@tomerqodo
Copy link

Benchmark PR dotnet#64732

Type: Clean (correct implementation)

Original PR Title: Improve Blazor reconnection experience after the server is restarted
Original PR Description: ## Background

In .NET 10, resuming a Blazor circuit fails when the server has been restarted (and an out-of-process persistent storage is not used). Currently, this is handled on the client side by displaying a "reconnection failed" UI which requires the user to manually reload the page. Previously, in .NET 9 the page would reload automatically once the server has restarted.

Changes

  • Re-adds the default reloading behavior to:
    • the ReconnectModal component used in the Blazor project template
    • the DefaultReconnectDisplay implementation used in the framework as the fallback when no reconnection UI is found in the user code
  • Modifies the ComponentHub on the server to not send a client error when ResumeCircuit fails because of unavailable circuit state.
    • This error caused the "yellow bar" to appear in the application. The error could not be caught by the client-side reconnection logic as it was processed elsewhere by the hubs's handler (for the "JS.Error" message).
    • The PR changes ComponentHub.ResumeCircuit to only return a falsy result in the case of unavailable state (similarly to how ConnectCircuit indicates rejection), allowing the client-side reconnection logic to react to the rejection by the server properly.
  • Updates the behavior in DefaultReconnectionHandler.attemptPeriodicReconnection so that the display does not switch between "reconnect" and "pause" states.
    • This created a bad user experience because the information displayed in the reconnection modal would flicker between the two variants which can be confusing both visually and message-wise.
    • The PR change keeps the same logic for reconnection attempts (try to reconnect, then try to resume) but keeps the UI in the "reconnect" state.
    • Reasoning: The fact that automatic reconnection can now involve resuming circuit with state stored on the server is an internal technical detail of the overall workflow that should not be surfaced to users, especially when this would be displayed only for few seconds before the page reload happens.
  • In one case the PR replaces reloading the page with just displaying a message: In the resume action that is invoked by the Resume button in the ReconnectionModal template. Now the page is reloaded only after server rejection, while normal failure (e.g. network issue) does not reload the page. This brings parity with the default UI.
    • Reasoning: We don't want to do automatic reload after failed resume from a graceful pause.
  • Adds E2E tests that check reconnection behavior without server state.
    • These emulate the situation when the server restarted and has lost state for the client's circuit.

Fixes dotnet#64228
Original PR URL: dotnet#64732

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