fix(socket_mode): recreate a closed aiohttp session when reconnecting - #1966
Open
Shubham-Padkonde wants to merge 1 commit into
Open
Shubham-Padkonde wants to merge 1 commit into
Shubham-Padkonde wants to merge 1 commit into
Conversation
The aiohttp SocketModeClient shares one ClientSession across all connections. Once it was closed, every reconnect attempt failed with "Session is closed" and connect() retried forever. Recreate the session at the start of a connection attempt when it is closed, and report a closed session as not connected. Fixes slackapi#1922 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Fixes #1922.
The aiohttp
SocketModeClientshares oneClientSessionfor all connections. Once that session was closed, every attempt inconnect()'s retry loop failed withRuntimeError: Session is closedand the client retried forever.connect()now creates a new session at the start of an attempt when the current one is closed. The loop still stops once the client itself is closed, soclose()does not trigger a new session.is_connected()returnsFalsewhen the session is closed, so health checks built on it can detect this state.The added test closes the session, runs
connect()withws_connectstubbed, and checks that the connection attempt uses a new open session; it fails before this change. The async Socket Mode tests, ruff and mypy pass.🤖 Generated with Claude Code