Closed EMaderbacher closed 1 month ago
Should be safe to just return null for the preloaded. On AnimateCarouselAsync returning false on null should just keep the slide from changing if I remember correctly. Though not sure why the preloading is getting called at all right now from a state the js runtime isn't ready.
On Wed, Sep 18, 2024 at 12:38 AM EMaderbacher @.***> wrote:
I get very often this exception:
System.NullReferenceException: Unable to load module. at BlazorStrap.Service.BlazorStrapInterop.PreloadModuleAsync(Nullable`1 cancellationToken) at BlazorStrap.Shared.Components.BSCoreBase.OnAfterRenderAsync(Boolean firstRender) at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)
What I've seen in webserver logs this happens when
- The webpage is opened
- The webpage is closed immediatelly, is refreshed or any other reason that the circuit has been closed
- The exception is always shown exactly 1 minute after the webpage was opened
The code throwing the exception is found here: https://github.com/EMaderbacher/BlazorStrap/blob/cb2654ed79fac96290dbfe6d78019864ffc2cb1a/src/BlazorStrap/Service/BlazorStrapInterop.cs#L325 In other places a null check is made and no exception is thrown, like here: https://github.com/EMaderbacher/BlazorStrap/blob/cb2654ed79fac96290dbfe6d78019864ffc2cb1a/src/BlazorStrap/Service/BlazorStrapInterop.cs#L337 Any chance that the exception isn't thrown and instead of that a null check is made?
The same exception is thrown here too: https://github.com/EMaderbacher/BlazorStrap/blob/cb2654ed79fac96290dbfe6d78019864ffc2cb1a/src/BlazorStrap/Service/BlazorStrapInterop.cs#L307 May a similar exception is thrown in other places too?
— Reply to this email directly, view it on GitHub https://github.com/chanan/BlazorStrap/issues/617, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJXJMR47247OZ2H2T3SR4DZXFJYRAVCNFSM6AAAAABONMEJS2VHI2DSMVQWIX3LMV43ASLTON2WKOZSGUZTGMZWHAZTQNY . You are receiving this because you are subscribed to this thread.Message ID: @.***>
I removed the thrown exceptions. The preloader doesn't care if it returns null and likely never should have. AnimateCarouselAsync will not just return true bypassing the animation.
I also wrapped NextAsync and BackAsync in a try-catch. This is because when navigating the timer might have just triggered and the task is still working. Since the elements are gone the array was out of range.
I get very often this exception:
What I've seen in webserver logs this happens when
The code throwing the exception is found here: https://github.com/EMaderbacher/BlazorStrap/blob/cb2654ed79fac96290dbfe6d78019864ffc2cb1a/src/BlazorStrap/Service/BlazorStrapInterop.cs#L325 In other places a null check is made and no exception is thrown, like here: https://github.com/EMaderbacher/BlazorStrap/blob/cb2654ed79fac96290dbfe6d78019864ffc2cb1a/src/BlazorStrap/Service/BlazorStrapInterop.cs#L337 Any chance that the exception isn't thrown and instead of that a null check is made?
The same exception is thrown here too: https://github.com/EMaderbacher/BlazorStrap/blob/cb2654ed79fac96290dbfe6d78019864ffc2cb1a/src/BlazorStrap/Service/BlazorStrapInterop.cs#L307 May a similar exception is thrown in other places too?