Skip to content
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

AssetPipeline.TryGetAssetFromRoute: System.InvalidOperationException: Collection was modified; enumeration operation may not execute. #66

Closed
AlexBar opened this issue Nov 22, 2017 · 2 comments · Fixed by #141

Comments

@AlexBar
Copy link
Contributor

AlexBar commented Nov 22, 2017

Time to time I'm getting the following exception when trying to access the page that uses a script by globing pattern:

System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
   at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
   at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
   at WebOptimizer.AssetPipeline.TryGetAssetFromRoute(String route, IAsset& asset) in D:\XXXXXXXXXXX\WebOptimizer.Core\AssetPipeline.cs:line 39
   at WebOptimizer.Taghelpers.ScriptTagHelper.Process(TagHelperContext context, TagHelperOutput output) in D:\XXXXXXXXXXX\WebOptimizer.Core\Taghelpers\ScriptTagHelper.cs:line 39
   at Microsoft.AspNetCore.Razor.TagHelpers.TagHelper.ProcessAsync(TagHelperContext context, TagHelperOutput output)
   at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner.<RunAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at AspNetCore._XXXXXXXXXXXXXXX___cshtml.<ExecuteAsync>d__14.MoveNext() in XXXXXXXXXXX.cshtml:line 0

To reproduce it I tried to open a few pages (~10 pages at once) after project build (clear cache and reload all tabs).

@bergkampx360
Copy link

Same issue here. After the server restarting, sometimes the first request (which tries to load multiple javascript files into the page) fails and throws the next exception:

An unhandled exception has occurred while executing the request.
System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
   at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
   at WebOptimizer.AssetPipeline.TryGetAssetFromRoute(String route, IAsset& asset)
   at WebOptimizer.AssetMiddleware.InvokeAsync(HttpContext context, IOptionsSnapshot`1 options)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass4_1.<UseMiddleware>b__2(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

WebOptimizer version: 1.0.236

@lahma
Copy link
Contributor

lahma commented Oct 26, 2020

Created #141 to fix this concurrency issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants