Azure / Azure/azure-functions-dotnet-worker
Function instances should be disposed after call
- Dominant language
- C#
- Stars
- 466
- Forks
- 215
- Avg merge
- 3d 10h
- Merged PRs (30d)
- 7
Description
Function instances, which contains any public methods with `[Function]` attributes, will never be disposed even they implement `IDisposable`.
### Expected behavior
Like ASP.NET Core's controllers,
* If the function instance implements `IAsyncDisposable`, its `DisposeAsync` should be called [after invocation](https://github.com/Azure/azure-functions-dotnet-worker/blob/a5fc0632d233b242debfd1485e527315567b9b3a/src/DotNetWorker.Core/Invocation/DefaultFunctionExecutor.cs#L46) even when the invocation throws.
* If the function instance implements `IDisposable`, its `Dispose` should be called after invocation even when the invocation throws.
* If the function instance implements both of `IAsyncDisposable` and `IDisposable`, `DisposeAsync` should be preferred.
### Actual behavior
Both of `IDisposable.Dispose()` and `IAsyncDisposable.DisposeAsync()` are never called.
### Runtime Information
* .NET 8
* Microsoft.Azure.Functions.Worker 1.20.0
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading the linked invocation logic in src/DotNetWorker.Core/Invocation/DefaultFunctionExecutor.cs and trace how function instances are created and invoked. Confirm that async disposal is preferred, disposal occurs after both successful and throwing invocations, and instances implementing only IDisposable are also disposed.
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
- Mostly clear
- Newbie friendliness
- 42/100