SixLabors / SixLabors/ImageSharp.Web
Exception when used locally in 4.0.0. Kestrel related?
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 446
- Forks
- 104
- PR merge metrics
- No merged PRs in 30d
Description
Prerequisites
- I have written a descriptive issue title
- I have verified that I am running the latest version of ImageSharp.Web
- I have verified if the problem exist in both
DEBUGandRELEASEmode - I have searched open and closed issues to ensure it has not already been reported
ImageSharp.Web version
4.0.0
Other Six Labors packages and versions
ImageSharp 4.0.0
Environment (Operating system, version and so on)
Windows 11, Kestrel
.NET version
10.0
Description
Since 4.0.0, when running ImageSharp.Web locally or in the CI/CD pipelines the following exception is thrown intermittently. On our production system (Azure App Service, Windows) it is not thrown at all.
fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HNM646UV6KOA", Request id "0HNM646UV6KOA:00000017": An unhandled exception was thrown by the application.
System.ArgumentException: An item with the same key has already been added. Key: autoorient
at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
at System.Collections.ObjectModel.KeyedCollection`2.AddKey(TKey key, TItem item)
at System.Collections.ObjectModel.KeyedCollection`2.InsertItem(Int32 index, TItem item)
at System.Collections.ObjectModel.Collection`1.Insert(Int32 index, T item)
at SixLabors.ImageSharp.Web.Middleware.ImageSharpMiddlewareOptions.<>c.<.ctor>b__56_1(ImageCommandContext context)
at SixLabors.ImageSharp.Web.Middleware.ImageSharpMiddleware.Invoke(HttpContext httpContext, Boolean retry)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)
Based on the stacktrace, it seems like the following line is causing the issue: https://github.com/SixLabors/ImageSharp.Web/blob/592083f26961650592a3578f2058c01b242989df/src/ImageSharp.Web/Middleware/ImageSharpMiddlewareOptions.cs#L43
I have no clue why, could it be a concurrency issue?
Steps to Reproduce
Unknown at this point.
Images
Not applicable.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading src/ImageSharp.Web/Middleware/ImageSharpMiddlewareOptions.cs around line 43 and the ImageSharpMiddleware.Invoke path named in the stack trace. Investigate whether concurrent requests can add the autoorient key more than once, then establish a local or CI reproduction; done means the intermittent duplicate-key exception no longer occurs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 45/100