AsyncState breaks when used in multiple service collections #4959
Labels
area-fundamentals
bug
This issue describes a behavior which is not expected - a bug.
work in progress 🚧
Description
Current implementation of AsyncState has both its pool and
AsyncLocal
asstatic
fields, but the counter isn'tstatic
:extensions/src/Libraries/Microsoft.Extensions.AsyncState/AsyncState.cs
Line 17 in a8e1751
This counter is used to generate indexes of
IAsyncContext
s, thus when used within different service collections, it start to pointing to items that were added previously (and they have different types potentially).Reproduction Steps
Expected behavior
Code doesn't throw.
Actual behavior
The code throws
InvalidCastException
.Regression?
No
Known Workarounds
No response
Configuration
No response
Other information
Related discussion exists regarding the
IHttpContextAccessor
: aspnet/HttpAbstractions#753The text was updated successfully, but these errors were encountered: