Azure / Azure/azure-functions-host
Scope Disposed Error in V4 Functions
- Dominant language
- C#
- Stars
- 2k
- Forks
- 482
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 38
Description
I'm having an issue similar to #7874. I've attached a Visual Studio project with a minimal reproduction. The issue occurs when a service registered as a singleton accepts a dependency Func\ where Service is registered as scoped or transient. Similar to #7874, the first request is successful, but the second request errors with the error "Scope disposed{no name} is disposed and scoped instances are disposed and no longer available.".
To reproduce, open the solution from the attached zip, run the function app, and make 2 requests to http://localhost:7071/api/Function1
[V4BugRepro.zip](https://github.com/Azure/azure-functions-host/files/9271255/V4BugRepro.zip)
Contributor guide
Research direction
Open the attached V4BugRepro.zip in Visual Studio, run the function app, and reproduce the problem by making two requests to http://localhost:7071/api/Function1. Compare the singleton's Func dependency with the scoped or transient Service registration and trace when the scope is disposed. Done means the second request completes without the scope-disposed error.
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
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100