This repository was archived by the owner on Mar 23, 2026. It is now read-only.
fix lambda state reset method to shutdown esm workers correctly#13671
Merged
fix lambda state reset method to shutdown esm workers correctly#13671
Conversation
Test Results (amd64) - Integration, Bootstrap 5 files 5 suites 2h 0m 52s ⏱️ Results for commit 1eef829. |
LocalStack Community integration with Pro 2 files ± 0 2 suites ±0 1h 30m 33s ⏱️ - 28m 8s Results for commit 1eef829. ± Comparison against base commit 59e81ce. This pull request removes 1435 tests. |
joe4dev
approved these changes
Feb 2, 2026
Member
joe4dev
left a comment
There was a problem hiding this comment.
Thank you for this state reset fix 🩹
sidenote: async pollers for event invokes and provisioned concurrency might need similar considerations
| def on_before_state_reset(self): | ||
| for esm_worker in self.esm_workers.values(): | ||
| esm_worker.stop_for_shutdown() | ||
| self.esm_workers = {} |
Member
There was a problem hiding this comment.
praise: Thank you for explicitly resetting that state (which is done implicitly upon stopping relying on its ephemeral nature) ✨
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
While working on a project, I noticed that after calling
localstack state reset, the logs indicated that ESM workers were not shut down correctly. I have a simple SQS <- ESM -> Lambda setup, and after resetting the state, I continued to get error messages that look like they're coming from the worker:This PR simply replicates what
on_before_stopdoes, which is iterating over the ESM workers and stopping them. Additionally, we're now also clearing the state that holds references to the workers.Changes
Tests
Tested manually with a simple project:
localstack state reset, and observe that the logs are no longer producing the error outputRelated