You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue #131 already touched on this - but I'd like to suggest that while it discusses wanting to do cleanup after each invocation, there is also a use case for wanting to do cleanup on closure of the execution environment.
For cleanup within the context of an execution, the suggested approach from normj works well (just wrap the actual function handler's method body w/ a using statement, and have a custom class implement IDisposable.
However, if (for example) I wanted to Bootstrap a DI container in the constructor, and dispose of it when the execution environment "shuts down" the lack of support for IDisposable on the wrapping class becomes more apparent.
I considered using a destructor, but believe the shared contract of IDisposable is a better solution overall.
Reacted by Matheus Araujo, Juliano Leal Goncalves, sjd2021, Johnathan Barclay, Diego Garcia Lozano and D Smith
If you are wanting for code to be called when the Lambda service reclaims the execution environment there is no service hook for that to happen. When the Lambda service detects a frozen execution environment that hasn't been used in awhile it deletes the execution environment regardless of what is inside the execution environment.
Closing as there isn't anything more we can do from the .NET side. There would need to be a service behavior change for us to do anything more. For general Lambda comments I would suggest adding post to the Lambda forum where members of the Lambda team will see it. https://forums.aws.amazon.com/forum.jspa?forumID=186
Activity
normj commentedon Nov 12, 2018
If you are wanting for code to be called when the Lambda service reclaims the execution environment there is no service hook for that to happen. When the Lambda service detects a frozen execution environment that hasn't been used in awhile it deletes the execution environment regardless of what is inside the execution environment.
nerdamigo commentedon Nov 12, 2018
Well that's too bad - was there a design decision for the Lamda environment that precludes it from offering such a service hook?
normj commentedon Feb 9, 2019
Closing as there isn't anything more we can do from the .NET side. There would need to be a service behavior change for us to do anything more. For general Lambda comments I would suggest adding post to the Lambda forum where members of the Lambda team will see it. https://forums.aws.amazon.com/forum.jspa?forumID=186
Dreamescaper commentedon Oct 16, 2025
@normj
Hi!
Is this still true?
Per my understanding, Lambda now sends SIGTERM signal to runtime before killing it. Would it be possible to use it for disposal?