ligershark / WebOptimizer

A bundler and minifier for ASP.NET Core
Apache License 2.0
771 stars 114 forks source link

InvalidOperationException in Asset.cs #228

Open jasonliao-cb opened 2 years ago

jasonliao-cb commented 2 years ago

this is a long issue from the earlier version and it should have a higher priority. Our production has seen this a couple of times

Error Message 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. 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.Dictionary.FindEntry(TKey key) at System.Collections.Generic.Dictionary.ContainsKey(TKey key) at WebOptimizer.Asset.GenerateCacheKey(HttpContext context) at WebOptimizer.AssetBuilder.BuildAsync(IAsset asset, HttpContext context, IWebOptimizerOptions options) at WebOptimizer.AssetMiddleware.HandleAssetAsync(HttpContext context, IAsset asset, WebOptimizerOptions options) at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)

https://github.com/ligershark/WebOptimizer/blob/ffbb49f0685779ad10d7b4b9299e47042808349c/src/WebOptimizer.Core/Asset.cs#L180

Error Message 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. 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.Dictionary.TryInsert(TKey key, TValue value, InsertionBehavior behavior) at System.Collections.Generic.Dictionary.set_Item(TKey key, TValue value) at WebOptimizer.Asset.ExpandGlobs(IAsset asset, IWebHostEnvironment env) at WebOptimizer.Asset.GenerateCacheKey(HttpContext context) at WebOptimizer.Taghelpers.BaseTagHelper.GenerateHash(IAsset asset) at WebOptimizer.Taghelpers.LinkTagHelper.Process(TagHelperContext context, TagHelperOutput output) at Microsoft.AspNetCore.Razor.TagHelpers.TagHelper.ProcessAsync(TagHelperContext context, TagHelperOutput output) at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner.RunAsync(TagHelperExecutionContext executionContext)

code below: https://github.com/ligershark/WebOptimizer/blob/ffbb49f0685779ad10d7b4b9299e47042808349c/src/WebOptimizer.Core/Asset.cs#L35 https://github.com/ligershark/WebOptimizer/blob/ffbb49f0685779ad10d7b4b9299e47042808349c/src/WebOptimizer.Core/Asset.cs#L135

this is also refer to the issue https://github.com/ligershark/WebOptimizer/issues/101

jasonliao-cb commented 2 years ago

this is very critical and will impact all pages will not able to display.

jasonliao-cb commented 2 years ago

@madskristensen can we have any update on this?