Skip to content

[release/11.0] Avoid sending JSInterop calls when component is disposed - #69522

Merged
wtgodbe merged 1 commit into
release/11.0from
backport/pr-69517-to-release/11.0
Oct 7, 2026
Merged

wtgodbe merged 1 commit into
release/11.0from
backport/pr-69517-to-release/11.0

Conversation

@github-actions

@github-actions github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Backport of #69517 to release/11.0

/cc @ilonatommy

Avoid sending JSInterop calls when component is disposed

This change centralizes disposal handling in VirtualizeJsInterop, which owns the object reference. It consists of:

  • Marking the interop wrapper as disposed before starting cleanup. That prevents JS interop calls after disposal started.
  • Handling ObjectDisposedException when disposal races with an invocation already starting.

Description

Virtualize<TItem> can be disposed while an asynchronous JS interop operation is pending. When the operation completes, the lifecycle continuation may issue another interop call using the component's disposed DotNetObjectReference, resulting in an ObjectDisposedException and circuit termination.

Fixes #69501

Customer Impact

Interactive server apps that use Virtualize component can occasionally terminate the circuit on navigation (or another render-tree updates that removes the component while JS interop is pending).

The failure was reproduced in the Aspire Dashboard through rapid navigation and in a standalone Blazor Server application. When it occurs, the browser displays the unhandled-error UI and the user must reconnect or reload the application.

There is no workaround other than avoiding the affected navigation timing.

Regression?

  • Yes
  • No

This is a lifetime race in the existing virtualization implementation that has been there since the beginning.

Risk

  • High
  • Medium
  • Low

The change is internal and does not alter public API. It only changes behavior after VirtualizeJsInterop disposal has started.

Exception handling is limited to ObjectDisposedException. Other interop exceptions continue to propagate normally. Browser-side disposal still bypasses the ordinary-call guard so required cleanup can run.

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

* Regression test for the report.

* Guard all outcomming JSInterop calls with disposal check.
@github-actions
github-actions Bot requested a review from a team as a code owner September 25, 2026 15:20
@ilonatommy ilonatommy self-assigned this Sep 25, 2026
@ilonatommy ilonatommy added the area-blazor Includes: Blazor, Razor Components label Sep 25, 2026
@ilonatommy ilonatommy added the Servicing-consider Shiproom approval is required for the issue label Sep 28, 2026
@dotnet-policy-service

Copy link
Copy Markdown
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.

@kotlarmilos kotlarmilos added Servicing-approved Shiproom has approved the issue and removed Servicing-consider Shiproom approval is required for the issue labels Sep 29, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Hi @github-actions[bot]. This PR was just approved to be included in the upcoming servicing release. Somebody from the @dotnet/aspnet-build team will get it merged when the branches are open. Until then, please make sure all the CI checks pass and the PR is reviewed.

@rbhanda rbhanda added this to the 11.0.0 milestone Sep 29, 2026
@wtgodbe
wtgodbe merged commit a65894d into release/11.0 Oct 7, 2026
51 checks passed
@wtgodbe
wtgodbe deleted the backport/pr-69517-to-release/11.0 branch October 7, 2026 17:21
@dotnet-policy-service dotnet-policy-service Bot removed this from the 11.0.0 milestone Oct 7, 2026
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 Servicing-approved Shiproom has approved the issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants