Exceptions thrown at irregular intervals

Hi There,

I have a page that's got a 3-4 different custom Blazor components (mine), and some of those components have SFDIALOGS in them. I have noticed lately (since 18.2.47, and also in 18.2.48) that the following random exception gets thrown when I visit the page. It does not always happen, but it does occur quite regularly, usually about 30-45 s after the page loads. It happens when I don't interact with the dialogs at all.


--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.ExecuteBackground(WorkItem item)
fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111]
      Unhandled exception in circuit 'KDA1ZMSBJc-0TqzIJta-U-gWcIfKvkf-GhvzOAGDOaE'.
System.Threading.Tasks.TaskCanceledException: A task was canceled.
   at Microsoft.JSInterop.JSRuntime.InvokeWithDefaultCancellation[T](String identifier, Object[] args)
   at Microsoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntime jsRuntime, String identifier, Object[] args)
   at Syncfusion.Blazor.SfBaseComponent.InvokeMethod(String methodName, Object[] methodParams)
   at Syncfusion.Blazor.Popups.SfDialog.ComponentDispose()
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__139_0(Object state)
   at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.ExecuteSynchronously(TaskCompletionSource`1 completion, SendOrPostCallback d, Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.ExecuteBackground(WorkItem item)

Any ideas on how I can prevent this?  

Here is (one of the) dialogs:

<SfDialog @bind-Visible="@IsVisible" Width="250px" ShowCloseIcon="false" IsModal="true">
    <DialogTemplates>
        <Header>@Header</Header>
        <Content>@((MarkupString)Content)</Content>
    </DialogTemplates>
    <DialogButtons>
        <DialogButton OnClick="@OkClick">
            <DialogButtonModel Content="OK" IsPrimary="true"></DialogButtonModel>
        </DialogButton>
        <DialogButton OnClick="@CancelClick">
            <DialogButtonModel Content="Cancel"></DialogButtonModel>
        </DialogButton>
    </DialogButtons>
</SfDialog>


Thanks
Joseph 

10 Replies

IS Indrajith Srinivasan Syncfusion Team August 20, 2020 01:35 PM UTC

Hi Joseph,  
  
Greetings from Syncfusion support,  
  
We have validated your reported issue with shared information. We have script issues in dialog with the version 18.2.45, while navigating pages with other components inside SfDialog which is resolved in the later versions of 18.2.47 & 18.2.48. We have tried to replicate the issue with the following ways and unfortunately we couldn’t reproduce the reported script issue with dialog. We have also prepared a sample using the version 18.2.48 with dialog rendered. 
  • Navigating to different page disposing the SfDialog.
  • Reloading the SfDialog rendered in the page multiple times. 
  • Leaving the page idle for a while, after the dialog is rendered.
  
Can you provide us the following details, 
  • Can you comment the Dialog component razor codes in your application then check and confirm whether the reported issue persists from your end?
  • Have you used any JsInterop file from your application end?
  • If possible, can you replicate the issue in the above sample and revert back to us?
  • Share us the different components you have used in the page?
The above details will be helpful for us to validate and provide solution at earliest. 
Regards,  
Indrajith 



TR Tom Rebbettes August 21, 2020 10:13 PM UTC

I have managed to reliably reproduce this error. Please see...


In the application I use JSRuntime to open a new tab with a dialog in it.
I then use JSRuntime to call window.close();

The error occurs in the output precisely 60 seconds after closing that tab with a dialog.




IS Indrajith Srinivasan Syncfusion Team August 24, 2020 12:11 PM UTC

Hi Tom / Joseph,

Good day to you,
 
 
We have validated your reported query. The script error doesn’t affect the SfDialog Rendering and shows only in the VS output. On further validation, the reported issues occurs due to the Blazor Dispose() lifecycle doesn’t work properly, and blazor team have considered as an feature request of introducing the new lifecycle event. Check the below link for reference.

Github query: https://github.com/dotnet/aspnetcore/issues/13026

Regards,
 
Indrajith 



TR Tom Rebbettes August 24, 2020 07:54 PM UTC

Understood.

It does however spam your application logs with errors. Particularly if you are relying heavily on dialogs...

Perhaps handeling this error in a try/catch until MS improve the life cycle handeling would be good to avoid spamming logs. 

But thanks for your response. 


RK Revanth Krishnan Syncfusion Team August 25, 2020 03:20 PM UTC

Hi Tom,  
 
 
Good day to you.  
 
 
We are currently checking the possibilities of “handling the exception” and will update you with further details on 27th September. 
  
Regards,  
Revanth 



IS Indrajith Srinivasan Syncfusion Team August 27, 2020 03:01 PM UTC

Hi Tom,

We have further validated on the reported query. We have already handled the try/catch exceptions in SfDialog. Since the exceptions arises directly from the Blazor after Dispose() called from the SfDialog.
 
We have also raised a query for any alternate way of resolving the error log with Blazor team and will let you know if we got any solution to overcome.  
 
Regards, 
Indrajith 



JT Joseph Tan September 1, 2020 01:15 AM UTC

Hi There,

My page which throws the original exception also throws a new one now: 

 TypeError: Cannot read property 'querySelectorAll' of undefined
    at Object.e.removeResize (http://localhost:5000/_content/Syncfusion.Blazor/scripts/popupsbase-f0313a.min.js:1:11225)
    at t.setEnableRTL (http://localhost:5000/_content/Syncfusion.Blazor/scripts/sf-dialog-f0313a.min.js:1:6993)
    at t.render (http://localhost:5000/_content/Syncfusion.Blazor/scripts/sf-dialog-f0313a.min.js:1:3140)
    at t.initialize (http://localhost:5000/_content/Syncfusion.Blazor/scripts/sf-dialog-f0313a.min.js:1:582)
    at Object.initialize (http://localhost:5000/_content/Syncfusion.Blazor/scripts/sf-dialog-f0313a.min.js:1:17626)
    at http://localhost:5000/_framework/blazor.server.js:8:31619
    at new Promise (<anonymous>)
    at e.beginInvokeJSFromDotNet (http://localhost:5000/_framework/blazor.server.js:8:31587)
    at http://localhost:5000/_framework/blazor.server.js:1:20052
    at Array.forEach (<anonymous>)
   at Microsoft.JSInterop.JSRuntime.InvokeWithDefaultCancellation[T](String identifier, Object[] args)
   at Microsoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntime jsRuntime, String identifier, Object[] args)
   at Syncfusion.Blazor.Internal.SfBaseUtils.InvokeMethod(IJSRuntime jsRuntime, String methodName, Object[] methodParams)
   at Syncfusion.Blazor.SfBaseComponent.InvokeMethod(String methodName, Object[] methodParams)
   at Syncfusion.Blazor.Popups.SfDialog.OnAfterScriptRendered()
   at Syncfusion.Blazor.SfBaseComponent.OnAfterRenderAsync(Boolean firstRender)
   at Syncfusion.Blazor.Popups.SfDialog.OnAfterRenderAsync(Boolean firstRender)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)
   

My setup:

I am using 18.2.0.55. I have an admin page which contains 4-5 components (my own) and those components contain SFDIALOGs.  The user enters values in the admin page, and saves the result to database

When it occurs:

Its not consistently reproducible. The page, when loaded, will throw this exception about 33% of the time, even if the user is not doing anything. It will throw the exception before the page is rendered. When the exception occurs, the page has to be reloaded.  66% of the time, the exception is not thrown, and the page works just fine  (user can make changes and save)


Can you give me some hints on how to troubleshoot this?
   


IS Indrajith Srinivasan Syncfusion Team September 1, 2020 02:39 PM UTC

Hi Joseph, 
 
Good day to you, 
 
We have validated your reported query with SfDialog using the Nuget version 18.2.55 and unable to reproduce the reported script error “Cannot read property 'querySelectorAll' of undefined”. Can you please share us the following details. 
 
  • Share us the different components you have used in the page?
  • Can you please share us the code blocks of the SfDialogs used in your application ?
 
Since we are unable to reproduce the issue locally. The above details will be helpful for us to further investigate on the reported issue. 
 
Regards, 
Indrajith 



JT Joseph Tan September 2, 2020 03:52 AM UTC

Can you provide me with a private channel so I can share the code?


IS Indrajith Srinivasan Syncfusion Team September 2, 2020 12:26 PM UTC

Hi Joseph, 
 
We have created a new incident under your Direct trac account to follow up with this query. We suggest you to follow up with the incident for further updates. Please log in using the below link.  
 
 
Regards, 
Indrajith 


Loader.
Up arrow icon