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

clean up global event listener, when connection closed #57828

Open
zuizuihao opened this issue Sep 12, 2024 · 4 comments
Open

clean up global event listener, when connection closed #57828

zuizuihao opened this issue Sep 12, 2024 · 4 comments
Labels
area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug.

Comments

@zuizuihao
Copy link

I found the ROOT CAUSE, @javiercn can we clean up the global event listener, when connection closed?
when Blazor connection closed, the detachWebRendererInterop in the callback of connection.onclose will be invoked. here, it will invoke interopMethodsByRenderer.delete(rendererId);, all the interopMethodsByRenderer will be cleaned. also There are lots of global event listener in form.js like window.addEventListener('focus'), window.addEventListener('keydown'). if user still interact with our app like focus, click, the global event will be triggered, then invoked EventDelegator.onGlobalEvent, invoked EventDelegator.dispatchGlobalEventToAllElements invoked WebRendererInteropMethods.dispatchEvent invoked WebRendererInteropMethods.getInteropMethods, here since the interopMethodsByRenderer is empty, will throw this exception.

Originally posted by @zuizuihao in #56813 (comment)

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-blazor Includes: Blazor, Razor Components label Sep 12, 2024
@javiercn
Copy link
Member

@zuizuihao thanks for contacting us.

Does this happen when you use MapRazorComponents and blazor.web.js or are you still relying on MapRazorComponents with blazor.server.js.

@javiercn javiercn added Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. and removed investigate labels Sep 12, 2024
@zuizuihao
Copy link
Author

nope, now we totally migrated into ASP.Net 8 using web.js.
<script src="_framework/blazor.web.js?version=8"></script> in App.razor script body.
endpoints.MapRazorComponents().AddInteractiveServerRenderMode()

@dotnet-policy-service dotnet-policy-service bot added Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. and removed Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. labels Sep 12, 2024
@mkArtakMSFT mkArtakMSFT added bug This issue describes a behavior which is not expected - a bug. and removed Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. labels Sep 12, 2024
@mkArtakMSFT mkArtakMSFT added this to the .NET 10 Planning milestone Sep 12, 2024
@lofcz
Copy link
Contributor

lofcz commented Oct 13, 2024

This is a showstopper issue we also ran into, please consider upping the priority on resolving this given the call stack is already figured out.

@zuizuihao
Copy link
Author

Hi @javiercn , I draft a PR for it to fix it, hope you can help us review it, we just don't want it to throw exception. when it's to be an exception will trigger different handle logic in our system.
#58667

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 bug This issue describes a behavior which is not expected - a bug.
Projects
None yet
Development

No branches or pull requests

4 participants