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

Update Table.razor.cs #2797

Merged
merged 2 commits into from
Oct 20, 2022
Merged

Update Table.razor.cs #2797

merged 2 commits into from
Oct 20, 2022

Conversation

Kyojuro27
Copy link
Contributor

@Kyojuro27 Kyojuro27 commented Oct 12, 2022

πŸ€” This is a ...

  • Bug fix

πŸ”— Related issue link

#2794

πŸ’‘ Background and solution

  1. I would like to point out an issue which occured when the SignalR connection is disconnected. In the company I'm working with, we are actually using Ant-Design-Blazor UI in several applications and it works well. But after a certain amount of time, we noticed in the Windows Event Viewer where our apps and IIS are installed that many Error and Warning are displayed.

Here the details of the Error:

Category: Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer
EventId: 100

Unhandled exception rendering component: JavaScript interop calls cannot be issued at this time. This is because the circuit has disconnected and is being disposed.

Exception:
Microsoft.JSInterop.JSDisconnectedException: JavaScript interop calls cannot be issued at this time. This is because the circuit has disconnected and is being disposed.
at Microsoft.AspNetCore.Components.Server.Circuits.RemoteJSRuntime.BeginInvokeJS(Int64 asyncHandle, String identifier, String argsJson, JSCallResultType resultType, Int64 targetInstanceId)
at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, CancellationToken cancellationToken, Object[] args)
at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args)
at Microsoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntime jsRuntime, String identifier, Object[] args)
at AntDesign.AntComponentBase.JsInvokeAsync(String code, Object[] args)
at AntDesign.Table`1.DisposeAsync()
at Microsoft.AspNetCore.Components.RenderTree.Renderer.<>c__DisplayClass69_0.<g__HandleAsyncExceptions|1>d.MoveNext()

Our apps run in .NET 6.0, with Visual Studio 2022, in Blazor Server and 0.12.5 package version of Ant-Design-Blazor.

For information, it's not an issue you can see in your apps, even our logging error system doesn't see it. It occured when SignalR connection is disconnected. As we can see in the error details, it happened because of the method DisposeAsync() of the component Table. After a quick check, we can see that in this method we can foud in Table.razor.cs, there is a call to a jsInterop method.

  1. Since .NET 6.0, a JSDisconnectedException appeared when a jsInterop method is called in a Dispose function. I believe the recommended way is to wrap it in a try-catch and catch the JSDisconnectedException as shown below in order to stop windows event viewer to be plained with warning and error. Since event listeners stop existing after a page reload, there are no memory leaks.
    In DisposeAsync() Method of Tab.razor.cs, I add a try - catch around the JSInterop call method "await JsInvokeAsync(JSInteropConstants.UnbindTableScroll, _tableBodyRef);" in order to prevent some error and warning entry in the Windows Event Viewer.

πŸ“ Changelog

There is no changes from userside

In DisposeAsync() Method of Tab.razor.cs, I add a try - catch around the JSInterop call method "await JsInvokeAsync(JSInteropConstants.UnbindTableScroll, _tableBodyRef);" in order to prevent some error and warning entry in the Windows Event Viewer.
@github-actions
Copy link

github-actions bot commented Oct 12, 2022

@dnfadmin
Copy link

dnfadmin commented Oct 12, 2022

CLA assistant check
All CLA requirements met.

@codecov
Copy link

codecov bot commented Oct 20, 2022

Codecov Report

Base: 41.59% // Head: 41.63% // Increases project coverage by +0.04% πŸŽ‰

Coverage data is based on head (b4f0cc7) compared to base (bed2028).
Patch coverage: 0.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2797      +/-   ##
==========================================
+ Coverage   41.59%   41.63%   +0.04%     
==========================================
  Files         544      544              
  Lines       25712    25740      +28     
  Branches      260      260              
==========================================
+ Hits        10694    10718      +24     
- Misses      14978    14982       +4     
  Partials       40       40              
Impacted Files Coverage Ξ”
components/table/Table.razor.cs 0.00% <0.00%> (ΓΈ)
components/core/Component/Overlay/Overlay.razor.cs 69.18% <0.00%> (-1.17%) ⬇️
components/date-picker/RangePicker.razor.cs 53.46% <0.00%> (-0.34%) ⬇️
components/core/CssSizeLength.cs 86.07% <0.00%> (-0.29%) ⬇️
components/table/ColumnBase.cs 0.00% <0.00%> (ΓΈ)
components/descriptions/Descriptions.razor 0.00% <0.00%> (ΓΈ)
components/cascader/Cascader.razor 80.44% <0.00%> (+0.10%) ⬆️
components/core/Helpers/CssStyleBuilder.cs 88.23% <0.00%> (+88.23%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

β˜” View full report at Codecov.
πŸ“’ Do you have feedback about the report comment? Let us know in this issue.

components/table/Table.razor.cs Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants