Blazorise icon indicating copy to clipboard operation
Blazorise copied to clipboard

[Bug]: JSBreakpointModule throwing exceptions

Open njannink opened this issue 9 months ago • 4 comments

Blazorise Version

1.5.1

What Blazorise provider are you running on?

Material

Link to minimal reproduction or a simple code snippet

I see following JSException in our logs with multiple stacktraces. Don't know the rootcause yet, but all trace back to the JSBreakpointModule

System.AggregateException: Exceptions were encountered while disposing components. (Importing a module script failed.
undefined) (Importing a module script failed.
undefined)
 ---> Microsoft.JSInterop.JSException: Importing a module script failed.
undefined
   at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args)
   at Blazorise.Modules.BaseJSModule.<GetModule>g__InitializeModule|10_0()
   at Blazorise.Modules.BaseJSModule.InvokeSafeVoidAsync(String identifier, Object[] args)
   at Blazorise.Modules.JSBreakpointModule.UnregisterBreakpoint(IBreakpointActivator component)
   at Blazorise.Bar.DisposeAsync(Boolean disposing)
   at Blazorise.BaseAfterRenderComponent.DisposeAsync()
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.<>c__DisplayClass85_0.<<Dispose>g__HandleAsyncExceptions|1>d.MoveNext()
   --- End of inner exception stack trace ---
 ---> (Inner Exception #1) Microsoft.JSInterop.JSException: Importing a module script failed.
undefined
   at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args)
   at Blazorise.Modules.BaseJSModule.<GetModule>g__InitializeModule|10_0()
   at Blazorise.Modules.BaseJSModule.InvokeSafeVoidAsync(String identifier, Object[] args)
   at Blazorise.Modules.JSDropdownModule.Destroy(ElementReference elementRef, String elementId)
   at Blazorise.Dropdown.DisposeAsync(Boolean disposing)

Microsoft.JSInterop.JSException: Importing a module script failed.
undefined
   at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args)
   at Blazorise.Modules.BaseJSModule.<GetModule>g__InitializeModule|10_0()
   at Blazorise.Modules.BaseJSModule.InvokeSafeVoidAsync(String identifier, Object[] args)
   ...
   at Blazorise.BaseAfterRenderComponent.OnAfterRenderAsync(Boolean firstRender)
   at Blazorise.BaseComponent.OnAfterRenderAsync(Boolean firstRender)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

njannink avatar Apr 29 '24 19:04 njannink

What I can image that there are certain scenarios where this getBreakpoint fails causing the script loading to fail.

lastBreakpoint = getBreakpoint();

// Get the current breakpoint
export function getBreakpoint() {
    return window.getComputedStyle(document.body, ':before').content.replace(/\"/g, '');
}

njannink avatar Apr 29 '24 19:04 njannink

Possible will need to check if the DOM is ready before trying to access it:

https://stackoverflow.com/questions/8100576/how-to-check-if-dom-is-ready-without-a-framework

njannink avatar Apr 29 '24 19:04 njannink

I'm leaving this here in case we need it https://kristoffer-strube.dk/post/cancelling-long-running-jsinterop-calls/

stsrki avatar Apr 30 '24 06:04 stsrki

I actually see this error a lot now in our server logs making it a bit more urgent.

njannink avatar Apr 30 '24 17:04 njannink

It should be fixed in the latest 1.6 release.

stsrki avatar Jul 30 '24 08:07 stsrki