Azure / Azure/azure-functions-host
Scoped registrations resolve same instance between multiple httprequests
- Dominant language
- C#
- Stars
- 2k
- Forks
- 482
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 38
Description
We registered our DbContext as scoped, but we noticed, if we start multiple http requests, the context gets shared between the different requests, which leads to threading issues:
{
type: 'NotSupportedException',
message: "A second operation started on this context before a previous asynchronous operation completed. Use 'await' to ensure that any asynchronous operations have completed before calling another method on this context. Any instance members are not guaranteed to be thread safe."
}
Any feedback on how to fix this would be greatly appreciated.
Our setup:
- We enabled the flag "AzureWebJobsFeatureFlags": "EnableEnhancedScopes",
- Azure functions with HttpTriggers
- added references:
```
```
- project:
```
netcoreapp3.1
v3
<_FunctionsSkipCleanOutput>true
```
Contributor guide
Research direction
Start by reproducing concurrent HTTP-trigger requests with the Azure Functions v3 and EnableEnhancedScopes setup described in the report, then inspect how scoped registrations are created per request. Done means identifying whether the same DbContext instance crosses requests and documenting a verified fix or limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, csharp
- Domain
- backend, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100