Skip to content

fix(slack): close previous handler in connect() to prevent zombie Socket Mode connections#19181

Merged
kshitijk4poor merged 2 commits into
mainfrom
fix/slack-zombie-socket
May 3, 2026
Merged

fix(slack): close previous handler in connect() to prevent zombie Socket Mode connections#19181
kshitijk4poor merged 2 commits into
mainfrom
fix/slack-zombie-socket

Conversation

@kshitijk4poor

Copy link
Copy Markdown
Collaborator

Salvage of PR #18982 by @nftpoetrist. Fixes #18980.

connect() overwrote self._handler and self._app without closing the prior AsyncSocketModeHandler. A second connect() call (gateway restart/reconnect) left a zombie Socket Mode websocket alive, causing double-dispatch of every Slack event — producing double responses.

Parity fix with the already-merged Discord fix (#18758). Adds close-before-reassign guard + regression test.

Changes: gateway/platforms/slack.py (+15 lines), tests/gateway/test_slack.py (+54 lines), scripts/release.py (AUTHOR_MAP)
Tests: 2 passed in TestSlackConnectCleanup

nftpoetrist and others added 2 commits May 3, 2026 16:16
…ket Mode connections

SlackAdapter.connect() overwrote self._handler, self._app, and
self._socket_mode_task without closing the prior AsyncSocketModeHandler
first. If connect() was called a second time on the same adapter (e.g.
during a gateway restart or in-process reconnect attempt), the old Socket
Mode websocket stayed alive. Both the old and new connections received
every Slack event and dispatched it twice — producing double responses
with different wording, the same bug that affected DiscordAdapter (#18187,
fixed in #18758).

Fix: add a close-before-reassign guard at the start of the connection
setup path, mirroring the guard DiscordAdapter.connect() already has.
When self._handler is None (fresh adapter, first connect()) the block is
a harmless no-op. Scoped to the handler/app fields only — no behavior
change for any path that does not call connect() twice.

Fixes #18980
@kshitijk4poor kshitijk4poor merged commit 0a97ce6 into main May 3, 2026
9 of 10 checks passed
@kshitijk4poor kshitijk4poor deleted the fix/slack-zombie-socket branch May 3, 2026 10:47
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/slack Slack app adapter labels May 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/slack Slack app adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(slack): close previous handler/task in connect() to prevent zombie Socket Mode connections

3 participants