-
Notifications
You must be signed in to change notification settings - Fork 354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IAsyncDisposable support #3048
Comments
Thanks for reporting pls share the app name,region,invoction id etc. |
I think it is not Azure resource specific. Is the actual Azure resource required to report SDK issue? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As described .NET documentation, developers expect that services (and function instances) should be disposed even when they only implement
IAsyncDisposable
. In fact,IServiceProvider
created from
Microsoft.Extensions.DependencyInjection.ServiceCollection
handlesIAsyncDisposable
, but Azure Function runtime does not. It leads resource leaks caused by objects which only implementIAsyncDisposable
, includingServiceBusSender
andServiceBusReceiver
of the Azure ServcieBus, they eventually causes receive link exhausion.This issue is same as #2870, which was closed as "completed" but it was not solved.
Repro steps
IAsyncDisposable
for your function class or your service class.DisposeAsync()
of function isntances, transient services, and scoped services never be called.DisposeAsync()
of singleton services never be called.Expected behavior
If functions and services implement
IAsyncDisposable
, theirDisposeAsync()
will be called in end of their lifetime.If they also implement
IDisposable
,IAsyncDisposable.DisposeAsync()
should be preferred.Actual behavior
DisposeAsync()
never be called.Known workarounds
IAsyncDisposable
objects to fields of function instances and their dependencies.DisposeAsync()
should be called in graceful shutdown.IDisposable
, so it is incomplete workaround.Related information
As far as I saw, following methods should be fixed. I am ready to create PR if my assumption is right.
IAsyncDisposable.DisposeAsync
to:*Scope
* Also fix
TrackDisposable
to recordIAsyncDisposable
AsyncDispose()
in:IAsyncDisposable.DisposeAsync()
methods described above.There are many DI related classes in azure-functions-host repo, so it is OK to post issue if needed.
The text was updated successfully, but these errors were encountered: