-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Blazor Index Out of Range Exception #6385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for contacting us, @cyberjaws. |
This bug still exists in Razor Components 3.0 preview 2 (end of Jan2019).
I've seen multiple threads doing I'm using no timers but just some |
Also experiencing this issue here using Razor Components from ASP.NET Core 3.0 Preview 2. |
I ported my app to Core 3.0 Preview 2. I was pleased to see cross threading exceptions from calling StateHasChanged() from a Threading.Timer's callback. (They been addressed using the newly supplied Invoke/InvokeAsync methods in the component's base. Thank you for addressing that!) Unfortunately I too still see this bug. |
For those tracking this ticket, it looks like some work has been done for the next release that should resolve this issue. Appears that the calls to the Renderer are going to be passed through an Invoker to ensure there won't be cross threaded access to the Dictionaries. |
Alas, I am still getting exceptions with Preview 3. |
Even with a try catch in Preview 3, the Signal R socket ends up disconnecting when this error occurs. |
Having the same problem, including SignalR disconnect. This is pretty disruptive... |
While I did not see the IndexOutOfRangeException since preview3, the display freeze followed by a SignalR timeout after 30s in browser still happens far too often. I made a test project for simulating this: https://github.com/springy76/RazorComponentsProblems/blob/problem/ConnectionDiesWhenUsingAsyncOperations/WebApp/Components/Pages/Index.razor Sometimes you only have to click some of the 12 buttons, sometimes you have to alternate for a minute. But sooner or later the display will freeze ("loading" text will not disappear, all buttons without function) and 30s later the browser will log connection timeout to debug console. Even after having disabled "just my code", and enabling every .net exception and every managed debugging assistant in exception settings, I did not see neither an exception in debugger nor deadlocked threads in thread-list. I wonder if anyone can narrow this down? |
@springy76 Thanks for posting. These could be related, however I would recommend creating another ticket for the disconnect and then link them. |
I changed my sample above and now it crashes always on first click of button 0-4 or 6-11. But only reproducible using a freshly started server. I've seen the exception happen a second time and then even after hitting F5 (which creates a new circuit) it did not happen again. Stacktrace:
|
Thanks @springy76. That is the same exception that this thread is tracking. Glad to see that you have code and a process that is repeatable. @SteveSandersonMS do you think this could be addressed before the official release? |
I've done some investigation, and now would like to discuss and re-triage. cc @mkArtakMSFT Although I've been unable to reproduce the 1. Use of
|
Would it be possible to resync that |
Sorry, no, it's too late. |
Thats sad. Since preview1 all of our beta testers get hit by this bug regularily and the only thing they notice is that the app (or sometimes even just a part of it) stops responding to clicks at any random time -- they don't see the exception stacktrace scroll by in console of course. Shouldn't this be fixable by a "simple" |
Describe the bug
Exception thrown: 'System.IndexOutOfRangeException' in System.Private.CoreLib.dll
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
I have a periodic task that runs at 1Hz and components that get their data and update their state call StateHasChanged() at that frequency.
To Reproduce
Blazor Components that register for this event call StateHasChanged() when appropriate.
Expected behavior
Dictionary can be added to.
Screenshots
N/A
Additional context
Likely this could be addressed by changing the Dictionary that houses the _eventBindings (and _componentStateById?) to a Concurrent Dictionary here:
https://github.com/aspnet/AspNetCore/blob/436b5461ad0337aac90089aa7ccb61dd875808e4/src/Components/src/Microsoft.AspNetCore.Components/Rendering/Renderer.cs
The text was updated successfully, but these errors were encountered: