Repository navigation
fix(socket_mode): end the builtin receive loop when its socket closes - #2104
Merged
Merged
Conversation
_run_current_session read current_session and current_session_state separately and reset terminated to False before running. During a reconnect it could run the new session on the previous, already terminated state and revive it, so close() terminated a state the runner was not watching and joined it forever. Read both once, check is_active() after the reads, and drop the reset. connect() retires the old session and state before publishing the new pair, so a mixed snapshot always holds a retired half and the runner skips it. The reset dates from when one state was shared across sessions (3.2.0b5); connect() has created a fresh state per session since 2021. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2104 +/- ##
=======================================
Coverage 84.96% 84.96%
=======================================
Files 118 118
Lines 14287 14287
=======================================
Hits 12139 12139
Misses 2148 2148 ☔ View full report in Codecov by Harness. |
run_until_completion kept sleeping on a closed socket until its state was terminated. A runner parked on a state nobody would terminate is what made close() join forever. A Connection never reopens its socket, so a closed socket means the session is over: return instead of parking. This makes any session and state mix-up harmless and covers RTM v2, which shares Connection. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
With the receive loop ending when its socket closes, a mismatched session and state can no longer hang close(), so the client-side pairing change and its end-to-end test are no longer needed. The unit test on Connection covers the fix. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
WilliamBergamin
marked this pull request as ready for review
December 2, 2026 17:51
mwbrooks
approved these changes
Dec 2, 2026
mwbrooks
left a comment
Member
There was a problem hiding this comment.
✅ Thanks @WilliamBergamin! Great find on the reused session state, and a one-line break is a nice small fix for a 180s hang.
This was referenced Dec 2, 2026
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This pull request makes the built-in
Connection.run_until_completionreturn once its socket closes, soSocketModeClient.close()no longer hangs after a reconnect.ConnectionStatewas terminated. Duringconnect(), the runner could pick up the previous, already terminated state and reset it to live.close()then terminated a different state, and since fix(socket_mode): shut down current_session_runner in built-in close() #1962 it joins the runner with no timeout. This is the 180s timeout seen intest_send_message_while_disconnectionon fix(oauth): close sqlite3 connections in the installation and state stores #2098 and feat(models): add data_table Block Kit block #1900.Connectionnever reopens its socket, so a closed socket means the session is over. The loop now exits instead of waiting for the flag.Connection.Testing
test_run_until_completion_returns_once_disconnecteddisconnects a runningConnectionand asserts the loop returns. It fails onmainand passes here:Category
/docs(Documents)/tutorial(PythOnBoardingBot tutorial)tests/integration_tests(Automated tests for this library)Requirements
python3 -m venv .venv && source .venv/bin/activate && ./scripts/run_validation.shafter making the changes.🤖 Generated with Claude Code