dotnet / dotnet/aspnetcore

IndexOutOfRangeException in Microsoft.AspNetCore.Server.IIS.Core.IISHttpContext.ExtraFeatureSet

Open
#56,762 2 comments 0 reactions 0 assignees View on GitHub
area-networking feature-iis
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the bug

Sometimes we get the following error logged:

```txt
IndexOutOfRangeException: Index was outside the bounds of the array.
at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContext.ExtraFeatureSet(Type key, Object value)
at Microsoft.AspNetCore.ResponseCompression.ResponseCompressionMiddleware.InvokeCore(HttpContext context)
```

Looking at the code there, I can't find anything that would cause this error if the code there is not accessed concurrently. Is it possible that, if a connection is aborted while for example the ResponseCompressionMiddleware is being executed, that this ExtraFeatureSet might get executed concurrently?

### Expected Behavior

No exception to occur.

### Steps To Reproduce

_No response_

### Exceptions (if any)

_No response_

### .NET Version

8.0.2

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.