Sporadic JSException during the start #992

Closed
opened 2026-01-29 17:47:26 +00:00 by claunia · 3 comments
Owner

Originally created by @OndrejUzovic on GitHub (Sep 20, 2023).

It seems there is a race condition issue causing an exception when the application starts.
If the exception occurs and I just refresh the web-page then everything is initialized correctly and the application works fine.

In my Blazor Server application I sporadically get the following exception:

[2023-09-20T11:46:22.745Z] Error: Microsoft.JSInterop.JSException: Could not find 'Radzen.mediaQuery' ('Radzen' was undefined).
Error: Could not find 'Radzen.mediaQuery' ('Radzen' was undefined).
    at https://localhost:44395/_framework/blazor.server.js:1:497
    at Array.forEach (<anonymous>)
    at s.findFunction (https://localhost:44395/_framework/blazor.server.js:1:465)
    at E (https://localhost:44395/_framework/blazor.server.js:1:2611)
    at https://localhost:44395/_framework/blazor.server.js:1:3499
    at new Promise (<anonymous>)
    at Ft.beginInvokeJSFromDotNet (https://localhost:44395/_framework/blazor.server.js:1:3480)
    at Ft._invokeClientMethod (https://localhost:44395/_framework/blazor.server.js:1:75072)
    at Ft._processIncomingData (https://localhost:44395/_framework/blazor.server.js:1:72696)
    at Ft.connection.onreceive (https://localhost:44395/_framework/blazor.server.js:1:67009)
   at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args)
   at Radzen.Blazor.RadzenMediaQuery.OnAfterRenderAsync(Boolean firstRender)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

Any idea why does it happen or haw can I avoid it?

Originally created by @OndrejUzovic on GitHub (Sep 20, 2023). It seems there is a race condition issue causing an exception when the application starts. If the exception occurs and I just refresh the web-page then everything is initialized correctly and the application works fine. In my Blazor Server application I sporadically get the following exception: ``` [2023-09-20T11:46:22.745Z] Error: Microsoft.JSInterop.JSException: Could not find 'Radzen.mediaQuery' ('Radzen' was undefined). Error: Could not find 'Radzen.mediaQuery' ('Radzen' was undefined). at https://localhost:44395/_framework/blazor.server.js:1:497 at Array.forEach (<anonymous>) at s.findFunction (https://localhost:44395/_framework/blazor.server.js:1:465) at E (https://localhost:44395/_framework/blazor.server.js:1:2611) at https://localhost:44395/_framework/blazor.server.js:1:3499 at new Promise (<anonymous>) at Ft.beginInvokeJSFromDotNet (https://localhost:44395/_framework/blazor.server.js:1:3480) at Ft._invokeClientMethod (https://localhost:44395/_framework/blazor.server.js:1:75072) at Ft._processIncomingData (https://localhost:44395/_framework/blazor.server.js:1:72696) at Ft.connection.onreceive (https://localhost:44395/_framework/blazor.server.js:1:67009) at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args) at Radzen.Blazor.RadzenMediaQuery.OnAfterRenderAsync(Boolean firstRender) at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState) ``` Any idea why does it happen or haw can I avoid it?
Author
Owner

@akorchev commented on GitHub (Sep 20, 2023):

This error happens if the Radzen.Blazor JS file fails to load for some reason (Radzen is undefined). You can't really avoid it as it could happen due to end-user browser settings.

@akorchev commented on GitHub (Sep 20, 2023): This error happens if the Radzen.Blazor JS file fails to load for some reason (Radzen is undefined). You can't really avoid it as it could happen due to end-user browser settings.
Author
Owner

@OndrejUzovic commented on GitHub (Sep 22, 2023):

Are there any particular browser settings which can cause it?
(In my case when it happens then after F5 (refresh) the page is reloaded and everything works fine.)

@OndrejUzovic commented on GitHub (Sep 22, 2023): Are there any particular browser settings which can cause it? (In my case when it happens then after F5 (refresh) the page is reloaded and everything works fine.)
Author
Owner

@akorchev commented on GitHub (Sep 22, 2023):

I don't know of any browser settings that can cause a JS file not to load.

@akorchev commented on GitHub (Sep 22, 2023): I don't know of any browser settings that can cause a JS file not to load.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#992