GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix lambda state reset method to shutdown esm workers correctly by thrau · Pull Request #13671 · localstack/localstack

This repository was archived by the owner on Mar 23, 2026. It is now read-only.

Conversation

@thrau

@thrau thrau commented Jan 31, 2026

Copy link
Copy Markdown
Contributor

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:

2026-01-31T14:34:46.821  INFO --- [et.reactor-1] localstack.request.http    : POST /_localstack/state/reset => 200
2026-01-31T14:34:47.230 ERROR --- [functhread12] l.s.l.e.esm_worker         : Error while polling messages for event source arn:aws:sqs:us-east-1:000000000000:messages-queue: An error occurred (AWS.SimpleQueueService.NonExistentQueue) when calling the ReceiveMessage operation: The specified queue does not exist.
2026-01-31T14:34:48.377 ERROR --- [functhread12] l.s.l.e.esm_worker         : Error while polling messages for event source arn:aws:sqs:us-east-1:000000000000:messages-queue: An error occurred (AWS.SimpleQueueService.NonExistentQueue) when calling the ReceiveMessage operation: The specified queue does not exist.

This PR simply replicates what on_before_stop does, 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

  • ESM workers are now shut down and removed correctly when resetting lambda state

Tests

Tested manually with a simple project:

  • Create a simple SQS/Lambda ESM setup, observe the esm worker logs that they are polling from the queue
  • call localstack state reset, and observe that the logs are no longer producing the error output
  • re-deploy the same resources again and make sure it still works (ensuring no breaking state side-effects)

Related

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@thrau
fix lambda state reset method to shutdown esm workers correctly
1eef829
@thrau
thrau requested review from dfangl, dominikschubert, gregfurman and joe4dev as code owners January 31, 2026 15:06
@thrau thrau added semver: patch Non-breaking changes which can be included in patch releases docs: skip Pull request does not require documentation changes notes: skip Pull request does not have to be mentioned in the release notes labels Jan 31, 2026
@github-actions

github-actions Bot commented Jan 31, 2026

Copy link
Copy Markdown

Test Results - Preflight, Unit

23 088 tests  ±0   21 229 ✅ ±0   6m 7s ⏱️ -1s
     1 suites ±0    1 859 💤 ±0 
     1 files   ±0        0 ❌ ±0 

Results for commit 1eef829. ± Comparison against base commit 59e81ce.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Jan 31, 2026

Copy link
Copy Markdown

Test Results (amd64) - Acceptance

7 tests  ±0   5 ✅ ±0   3m 2s ⏱️ +2s
1 suites ±0   2 💤 ±0 
1 files   ±0   0 ❌ ±0 

Results for commit 1eef829. ± Comparison against base commit 59e81ce.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Jan 31, 2026

Copy link
Copy Markdown

Test Results (amd64) - Integration, Bootstrap

    5 files      5 suites   2h 0m 52s ⏱️
3 767 tests 3 492 ✅ 275 💤 0 ❌
3 773 runs  3 492 ✅ 281 💤 0 ❌

Results for commit 1eef829.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Jan 31, 2026

Copy link
Copy Markdown

LocalStack Community integration with Pro

    2 files  ±    0      2 suites  ±0   1h 30m 33s ⏱️ - 28m 8s
3 743 tests  - 1 435  3 464 ✅  - 1 326  279 💤  - 109  0 ❌ ±0 
3 745 runs   - 1 435  3 464 ✅  - 1 326  281 💤  - 109  0 ❌ ±0 

Results for commit 1eef829. ± Comparison against base commit 59e81ce.

This pull request removes 1435 tests.
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_lambda_dynamodb
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_opensearch_crud
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_search_books
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_setup
tests.aws.scenario.kinesis_firehose.test_kinesis_firehose.TestKinesisFirehoseScenario ‑ test_kinesis_firehose_s3
tests.aws.scenario.lambda_destination.test_lambda_destination_scenario.TestLambdaDestinationScenario ‑ test_destination_sns
tests.aws.scenario.lambda_destination.test_lambda_destination_scenario.TestLambdaDestinationScenario ‑ test_infra
tests.aws.scenario.loan_broker.test_loan_broker.TestLoanBrokerScenario ‑ test_prefill_dynamodb_table
tests.aws.scenario.loan_broker.test_loan_broker.TestLoanBrokerScenario ‑ test_stepfunctions_input_recipient_list[step_function_input0-SUCCEEDED]
tests.aws.scenario.loan_broker.test_loan_broker.TestLoanBrokerScenario ‑ test_stepfunctions_input_recipient_list[step_function_input1-SUCCEEDED]
…
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

joe4dev
joe4dev approved these changes Feb 2, 2026
View reviewed changes

@joe4dev joe4dev left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this state reset fix 🩹

sidenote: async pollers for event invokes and provisioned concurrency might need similar considerations

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

thrau reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread localstack-core/localstack/services/lambda_/provider.py
def on_before_state_reset(self):
for esm_worker in self.esm_workers.values():
esm_worker.stop_for_shutdown()
self.esm_workers = {}

@joe4dev joe4dev Feb 2, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: Thank you for explicitly resetting that state (which is done implicitly upon stopping relying on its ephemeral nature) ✨

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@thrau
thrau merged commit a8c43f2 into main Feb 2, 2026
54 of 59 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@thrau
thrau deleted the fix-state-reset-on-lambda branch February 2, 2026 12:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@dominikschubert dominikschubert Awaiting requested review from dominikschubert
@dfangl dfangl Awaiting requested review from dfangl
@gregfurman gregfurman Awaiting requested review from gregfurman
1 more reviewer
@joe4dev joe4dev joe4dev approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

docs: skip Pull request does not require documentation changes notes: skip Pull request does not have to be mentioned in the release notes semver: patch Non-breaking changes which can be included in patch releases

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@thrau @joe4dev
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.