Skip to content
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

[release/8.0-preview5] Fix IJSObjectReference disposal #48522

Merged

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented May 30, 2023

Backport of #48287 to release/8.0-preview5

/cc @MackinnonBuck @LostBeard

Fix IJSObjectReference disposal

Fixes a bug where disposing an IJSObjectReference instance from .NET results in an exception getting thrown.

Description

IJSObjectReferences are useful for passing references to JavaScript objects between JS and .NET. After obtaining a IJSObjectReference via JS interop, it can be disposed from .NET via the IJSObjectReference.DisposeAsync() method. Due to some recent changes in Blazor's JavaScript implementation, disposing a JS object reference now throws the following exception:

Microsoft.JSInterop.JSException: Could not find 'DotNet.jsCallDispatcher.disposeJSObjectReferenceById' ('jsCallDispatcher' was undefined).
Error: Could not find 'DotNet.jsCallDispatcher.disposeJSObjectReferenceById' ('jsCallDispatcher' was undefined).

This PR fixes the issue by updating IJSObjectReference disposal according to the recent changes in Blazor's JS implementation.

Fixes #48280

Customer Impact

IJSObjectReference is commonly used by many Blazor apps and component libraries. While app developers could temporarily work around the issue by not disposing any IJSObjectReference instances, the change could make some component libraries unusable without a workaround.

Regression?

  • Yes
  • No

Regressed from .NET 8 Preview 4

Risk

  • High
  • Medium
  • Low

The change is just updating a string value that got out of sync with other changes. Most of the diff is caused by the additional tests added to catch this case in the future.

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

@github-actions github-actions bot requested a review from a team as a code owner May 30, 2023 18:41
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-blazor Includes: Blazor, Razor Components label May 30, 2023
@MackinnonBuck MackinnonBuck changed the title [release/8.0-preview5] Update JSInProcessObjectReference.cs [release/8.0-preview5] Fix IJSObjectReference disposal May 30, 2023
@mkArtakMSFT mkArtakMSFT added the Servicing-approved Shiproom has approved the issue label May 30, 2023
@ghost
Copy link

ghost commented May 30, 2023

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.

@mkArtakMSFT mkArtakMSFT merged commit 736282f into release/8.0-preview5 May 30, 2023
@mkArtakMSFT mkArtakMSFT deleted the backport/pr-48287-to-release/8.0-preview5 branch May 30, 2023 20:35
@ghost ghost added this to the 8.0-preview5 milestone May 30, 2023
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.

3 participants