Skip to content

fix(socket_mode): only release connect_operation_lock when send_message holds it - #2048

Merged
WilliamBergamin merged 3 commits into
slackapi:mainfrom
WilliamBergamin:fix/socket-mode-send-message-lock
Nov 16, 2026
Merged

WilliamBergamin merged 3 commits into
slackapi:mainfrom
WilliamBergamin:fix/socket-mode-send-message-lock

Conversation

@WilliamBergamin

Copy link
Copy Markdown
Contributor

Summary

This pull request stops the async Socket Mode adapters from releasing a connect_operation_lock that send_message doesn't hold.

  • websockets: the retry path in send_message never acquired the lock, but its finally released it whenever it was locked. A send that failed during a reconnect released the reconnect's lock.
  • aiohttp: if send_message was cancelled while it waited on the lock, the finally still saw it as locked and released the lock for the task that held it.
  • Both adapters now use async with self.connect_operation_lock:, so a release only ever follows the acquire.

Supersedes #1963. Thanks @dylanpulver for finding and reporting this. This is a separate implementation, because #1963 couldn't be merged without a signed CLA.

Testing

The new tests fail on main and pass on this branch, for both adapters:

  • Another task holds the lock.
  • The first send fails, so send_message retries and times out waiting on the lock.
  • The other task's lock is still held afterward.

Category

  • slack_sdk.web.WebClient (sync/async) (Web API client)
  • slack_sdk.webhook.WebhookClient (sync/async) (Incoming Webhook, response_url sender)
  • slack_sdk.socket_mode (Socket Mode client)
  • slack_sdk.signature (Request Signature Verifier)
  • slack_sdk.oauth (OAuth Flow Utilities)
  • slack_sdk.models (UI component builders)
  • slack_sdk.scim (SCIM API client)
  • slack_sdk.audit_logs (Audit Logs API client)
  • slack_sdk.rtm_v2 (RTM client)
  • /docs (Documents)
  • /tutorial (PythOnBoardingBot tutorial)
  • tests/integration_tests (Automated tests for this library)

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 python3 -m venv .venv && source .venv/bin/activate && ./scripts/run_validation.sh after making the changes.

🤖 Generated with Claude Code

WilliamBergamin and others added 2 commits November 16, 2026 15:03
…etries

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
…ge holds it

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@codecov

codecov Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.49%. Comparing base (25c14fb) to head (47e6a7c).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2048      +/-   ##
==========================================
- Coverage   84.51%   84.49%   -0.03%     
==========================================
  Files         118      118              
  Lines       14042    14037       -5     
==========================================
- Hits        11868    11860       -8     
- Misses       2174     2177       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@WilliamBergamin WilliamBergamin self-assigned this Nov 16, 2026
@WilliamBergamin WilliamBergamin added socket-mode bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented semver:patch labels Nov 16, 2026
@WilliamBergamin WilliamBergamin added this to the 3.47.1 milestone Nov 16, 2026
@WilliamBergamin
WilliamBergamin marked this pull request as ready for review November 16, 2026 21:52
@WilliamBergamin
WilliamBergamin requested a review from a team as a code owner November 16, 2026 21:52

@zimeg zimeg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🐍 @WilliamBergamin LGTM! Matching the sync clients with async with reads so much safer, and thanks for carrying this one forward from #1963!

@WilliamBergamin
WilliamBergamin merged commit 6a772c6 into slackapi:main Nov 16, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented semver:patch socket-mode

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants