chanan / BlazorStrap

Bootstrap 4 Components for Blazor Framework
https://blazorstrap.io
The Unlicense
916 stars 157 forks source link

Toaster Timer Throws Exception on Blazor Server #520

Closed zandermar18 closed 2 years ago

zandermar18 commented 2 years ago

When multiple toasts with timers are added to the toaster and at least one (but not all) are dismissed manually before the timeout occurs, an exception is sometimes thrown.

Sometimes an Enumerable out of range exception is thrown at Toaster.cs:71

Sometimes a JSInterop exception is thrown at BSToast.cs:137

It seems to be a transient error and is semi-reproducable. My guess is that the there is a thread concurrency issue going on here. It also appears to only be an issue on Blazor Server and not WASM, further implying it's a thread concurrency issue as WASM is single threaded. However since the root cause is unknown, it can't be ruled out that the issue also occurs on WASM.

jbomhold3 commented 2 years ago

This is a Quick fix for the issue. Might visit later on .

zandermar18 commented 2 years ago

Thanks for the quick fix, left a comment on the commit about one of the try blocks!

jbomhold3 commented 2 years ago

not able to produce the issue so if you can just do the pr where needed

zandermar18 commented 2 years ago

Put up a quick PR. I'm also having issues consistently reproducing the issue, so left it with the quick fix. I'd like to do the permanent at some point using a BlockingCollection<T> but need to be able to repro consistently first.