Skip to content

Preserve context variables in threaded listeners - #1632

Open
noooooooookro wants to merge 1 commit into
slackapi:mainfrom
noooooooookro:fix/listener-context-propagation
Open

noooooooookro wants to merge 1 commit into
slackapi:mainfrom
noooooooookro:fix/listener-context-propagation

Conversation

@noooooooookro

Copy link
Copy Markdown

Summary

A threaded listener can lose a correlation ID set by middleware. Bolt now copies the current context each time it submits an ack or lazy callback, including Django lazy listeners. If one callback rebinds that ID, the next callback on the same worker still sees the value set by middleware.

Fixes #1267.

Testing

The full suite passed on Linux with Python 3.11 (957 tests). One regression test dispatches a shortcut through a single-worker app and checks that each listener sees the middleware value. A second sends a signed request through the Django adapter and checks its lazy listener.

./scripts/run_tests.sh tests/scenario_tests/test_listener_context.py
./scripts/run_tests.sh tests/adapter_tests/django/test_django.py::test_django_lazy_listener_context

Category

  • slack_bolt.App and/or its core components
  • slack_bolt.async_app.AsyncApp and/or its core components
  • Adapters in slack_bolt.adapter
  • Document pages under /docs
  • Others

Requirements

  • I've read and understood the Contributing Guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I have signed the Salesforce CLA (required before your PR can be reviewed or merged).
  • I've run ./scripts/install_all_and_run_tests.sh after making the changes.

@noooooooookro
noooooooookro requested a review from a team as a code owner November 29, 2026 08:46
@salesforce-cla

Copy link
Copy Markdown

Thanks for the contribution! Before we can merge this, we need @noooooooookro to sign the Salesforce Inc. Contributor License Agreement.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Looking for advice on ThreadPool separation for middleware and actual event, looking for ContextVars to be passed

1 participant