RickStrahl / Westwind.AspnetCore.LiveReload

ASP.NET Core Live Reload Middleware that monitors file changes in your project and automatically reloads the browser's active page
Other
469 stars 42 forks source link

Use concurrent collections #29

Closed Mart-Bogdan closed 4 years ago

Mart-Bogdan commented 4 years ago

You are using non concurrent hashset

I think best option would be to use ConcurrecnyDictionary<WebSocket, object> where object is Null and only Keys are used


 Microsoft.AspNetCore.Server.Kestrel[13] Connection id "0HLVMHRJOJC89", Request id "0HLVMHRJOJC89:00000001": 
 An unhandled exception was thrown by the application.
System.InvalidOperationException: Operations that change non-concurrent collections must have exclusive access.
 A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct.
   at System.Collections.Generic.HashSet`1.Contains(T item)
   at Westwind.AspNetCore.LiveReload.LiveReloadMiddleware.HandleWebSocketRequest(HttpContext context)
   at Westwind.AspNetCore.LiveReload.LiveReloadMiddleware.InvokeAsync(HttpContext context)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

I've got this error during casual use of application.

Detected on 0.1.8 and confirmed on 0.2.3

RickStrahl commented 4 years ago

Thanks. Updated.