[release/10.0] Detach methods when disconnection confirmed.#66347
Open
github-actions[bot] wants to merge 2 commits intorelease/10.0from
Open
[release/10.0] Detach methods when disconnection confirmed.#66347github-actions[bot] wants to merge 2 commits intorelease/10.0from
github-actions[bot] wants to merge 2 commits intorelease/10.0from
Conversation
Contributor
|
Hi @github-actions[bot]. Please make sure you've updated the PR description to use the Shiproom Template. Also, make sure this PR is not marked as a draft and is ready-to-merge. To learn more about how to prepare a servicing PR click here. |
Contributor
|
Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #66275 to release/10.0
/cc @ilonatommy
Detach methods when disconnection confirmed.
Fix JSException "Interop methods are already registered for renderer 1" during reconnect→resume fallback.
Description
When a Blazor Server client disconnects (common on mobile),
DefaultReconnectionHandlercallsreconnect(). IfConnectCircuitfails (circuit expired), it falls back toresume(), which creates a newRemoteRendereron the server. That renderer's constructor callsattachWebRendererInterop(1, newMethods)via JS interop, butreconnect()had already re-attached saved interop methods and didn't clean them up whenConnectCircuitreturned false — causing the throw.The fix adds 3 lines in
CircuitManager.reconnect(): whenConnectCircuitreturns false, detach the interop methods (guarded byisRendererAttachedto handle edge cases where the renderer wasn't attached).Introduced by PR #62259 ("[Blazor] Adds support for persisting and restoring disconnected circuits from storage") which added the
resume()fallback after failedreconnect().Fixes #64738
Customer Impact
Users running Blazor Server apps on .NET 10 experience unobserved
JSExceptionwhen mobile clients disconnect and the circuit expires on the server. The exception surfaces viaTaskScheduler.UnobservedTaskException, which can crash the application if not explicitly caught.The bug prevents the .NET 10 circuit resume feature from working - the page is left non-functional and requires a manual refresh.
Workarounds exist: catching and ignoring the exception globally (page still broken, needs refresh, state that should be preserved in such situations in .net10 is lost), or providing a custom
reconnectionHandlerthat reloads instead of callingresume()(works correctly, equivalent to .NET 9 behavior, but forgoes the seamless resume feature and also looses the state).Regression?
The bug was added in resume and persisting state PR which is a new feature in .net10. However, from user's perspective it is a regression. In .net9 disconnection and reconnection never threw an exception because
resume()fallback didn't exist. Upgrading to .net10 introduces a crash.Risk
The fix code only executes in a failure path (when
ConnectCircuithas already returned false == the circuit is gone on the server). It cleans up stale client-side state (a JSMapentry) that would otherwise block the subsequentresume(). TheisRendererAttachedguard makes it a no-op when the renderer wasn't attached. No server-side changes, no public API changes, no protocol changes.The change cannot affect successful reconnections.
Verification
Packaging changes reviewed?