Open zuizuihao opened 4 weeks ago
@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
.
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
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 https://github.com/dotnet/aspnetcore/issues/56813#issuecomment-2345157777