-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Improve Blazor reconnection experience after the server is restarted #64732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR improves the Blazor reconnection experience when the server restarts by restoring the automatic page reload behavior that existed in .NET 9. The changes ensure that when a circuit cannot be resumed (e.g., because the server restarted and the circuit state is no longer available), the page automatically reloads instead of requiring manual user intervention.
Key Changes
- Modified server-side ComponentHub to return null instead of sending a client error when circuit state is unavailable during resume, allowing client-side reconnection logic to handle the rejection gracefully
- Updated client-side reconnection handlers to automatically reload the page when resume is rejected by the server
- Improved reconnection UI to avoid flickering between "reconnect" and "pause" states during automatic reconnection attempts
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Components/Server/src/ComponentHub.cs | Removed error notification to client when circuit state is unavailable, returning null instead to allow graceful handling by client reconnection logic |
| src/Components/Web.JS/src/Platform/Circuits/DefaultReconnectionHandler.ts | Removed unnecessary pause state transition during reconnection, calling rejected() directly when resume fails |
| src/Components/Web.JS/src/Platform/Circuits/DefaultReconnectDisplay.ts | Updated error message and button visibility for resume failures; changed rejected resume to call rejected() instead of failed() |
| src/Components/Web.JS/src/Platform/Circuits/UserSpecifiedDisplay.ts | Added remote field tracking and updated to pass remote flag in resume-failed events; changed reconnect default to true |
| src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWebCSharp.1/Components/Layout/ReconnectModal.razor | Updated resume button visibility and error message to show retry option |
| src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWebCSharp.1/Components/Layout/ReconnectModal.razor.js | Added modal close before reload on rejection; changed exception handling in resume to show failed state instead of reloading |
...mplates/content/BlazorWeb-CSharp/BlazorWebCSharp.1/Components/Layout/ReconnectModal.razor.js
Show resolved
Hide resolved
...mplates/content/BlazorWeb-CSharp/BlazorWebCSharp.1/Components/Layout/ReconnectModal.razor.js
Outdated
Show resolved
Hide resolved
|
/backport to release/10.0 |
|
Started backporting to |
|
@oroztocil backporting to git am output$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch
Applying: Improve Blazor reconnection experience after server restart
Applying: Update CannotResumeAppWhenPersistedComponentStateIsNotAvailable to reflect change in ResumeCircuit
Applying: Revert a minor UI change
Applying: Add E2E tests to check reconnection behavior without server state
Using index info to reconstruct a base tree...
M src/Components/test/testassets/Components.TestServer/RazorComponentEndpointsStartup.cs
Falling back to patching base and 3-way merge...
Auto-merging src/Components/test/testassets/Components.TestServer/RazorComponentEndpointsStartup.cs
CONFLICT (content): Merge conflict in src/Components/test/testassets/Components.TestServer/RazorComponentEndpointsStartup.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0004 Add E2E tests to check reconnection behavior without server state
Error: The process '/usr/bin/git' failed with exit code 128 |
javiercn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
|
/ba-g failure to download gradle added issue opened as KBE |
1 similar comment
|
/ba-g failure to download gradle added issue opened as KBE |
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
ReconnectModalcomponent used in the Blazor project templateDefaultReconnectDisplayimplementation used in the framework as the fallback when no reconnection UI is found in the user codeComponentHubon the server to not send a client error whenResumeCircuitfails because of unavailable circuit state.ComponentHub.ResumeCircuitto only return a falsy result in the case of unavailable state (similarly to howConnectCircuitindicates rejection), allowing the client-side reconnection logic to react to the rejection by the server properly.DefaultReconnectionHandler.attemptPeriodicReconnectionso that the display does not switch between "reconnect" and "pause" states.ReconnectionModaltemplate. 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.Fixes #64228