Repository navigation
fix: Non-blocking Slack Socket Mode startup with token validation - #214
Conversation
vybe
left a comment
There was a problem hiding this comment.
PR Validation Report
Files Changed: 3 (+43/-16) | Branch: slack-fixes → main
Issues Found
Critical (Block Merge)
-
Missing changelog entry —
docs/memory/changelog.mdnot updated. All PRs require a changelog entry. -
PR description claims Dockerfile + deploy script changes not present in diff — The body lists
COPY adapters/in Dockerfile andadaptersingcp-deploy.sh, but the diff only contains 3 Python files. If the Dockerfile isn't updated, theModuleNotFoundErrorthis PR claims to fix won't actually be resolved.
Warnings
-
No GitHub Issue linked — A production-blocking bug fix should have an associated issue for tracking.
-
Accessing private
_runningattribute —main.py:311andsettings.py:653both accesstransport._runningdirectly. Consider adding a@property is_connectedoris_runningmethod toSlackSocketTransport. -
Connect-before-stop ordering in
settings.py— Starting a new Socket Mode connection before stopping the old one could cause duplicate message processing during the overlap window. The previous stop-then-start approach is safer for Socket Mode.
Minor
slack_socket.py:37— f-string with no interpolated variables (f"Invalid Slack App Token format..."), use a plain string.
Required Changes
- Add changelog entry to
docs/memory/changelog.md - Include the Dockerfile and deploy script changes mentioned in description, or update description to match actual scope
- Link a GitHub Issue
🤖 Generated with Claude Code
Socket Mode client with an invalid token enters infinite retry loop, blocking the event loop and making the entire backend unresponsive. - Validate xapp- token format before attempting connection - Disable auto_reconnect on initial connect (prevent infinite retry) - Add 10s timeout on connect attempt - Enable auto_reconnect only after successful connection - Backend continues without Slack if connection fails (non-blocking) - Settings connect endpoint returns 400 with clear message on failure
…leanup - Add is_connected property to SlackSocketTransport (avoid _running access) - Use is_connected in main.py and settings.py - Fix f-string with no interpolation - Add changelog entry for 2026-03-27 - Document connect-before-stop trade-off Fixes #215
vybe
left a comment
There was a problem hiding this comment.
Validated against Trinity development methodology — all checks pass.
Documentation: Changelog entry present (minor nit: missing emoji prefix, not blocking).
Security: All 6 security checks passed — no secrets, credentials, or PII.
Code Quality: Well-scoped fix. Token validation, 10s timeout, graceful fallback, and is_connected property are all solid patterns.
Traceability: Links to #215.
LGTM ✅
Summary
Fixes production issue where Slack Socket Mode with an invalid token blocks the entire event loop, making the backend unresponsive.
Changes
Non-blocking Socket Mode (
adapters/transports/slack_socket.py)xapp-token format before attempting connectionauto_reconnecton initial connect (prevents infinite retry with bad token)connect()to prevent blocking startupdisconnect()before nulling)auto_reconnectonly after successful connectionis_connectedproperty (public API instead of_runningaccess)Startup resilience (
main.py)is_connectedafterstart()— if connection failed, log warning and continue without SlackSettings connect endpoint (
routers/settings.py)Test plan (all verified locally)
xapp-token → timed out at 10s, backend healthyModuleNotFoundError(PR fix: Add adapters/ to backend Dockerfile and deploy script #194)Fixes #215