Skip to content

Commit 0291587

Browse files
committed
feat(socket): add diagnostic heartbeat and raw message logging
Debug logging to diagnose silent connection failures: - Heartbeat every 60s showing connection state - Log raw messages as they arrive to confirm thread is alive Signed-off-by: Jon Whitcraft <jwhitcraft@mac.com>
1 parent 3fbe122 commit 0291587

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/bolt_rb/socket_mode/client.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,18 @@ def connected?
9999
#
100100
# @return [void]
101101
def run_loop
102+
last_heartbeat = Time.now
103+
heartbeat_interval = 60 # Log every 60 seconds
104+
102105
while @running
103106
sleep 0.1
104107
reconnect_if_needed
108+
109+
# Periodic heartbeat to confirm the loop is alive
110+
if Time.now - last_heartbeat >= heartbeat_interval
111+
logger.debug "[SocketMode] Heartbeat: connected=#{connected?}, websocket_open=#{@websocket&.open?}"
112+
last_heartbeat = Time.now
113+
end
105114
end
106115
ensure
107116
# Clean up websocket when loop exits
@@ -206,6 +215,8 @@ def handle_open
206215
# @param msg [WebSocket::Client::Simple::Message] The message
207216
# @return [void]
208217
def handle_message(msg)
218+
logger.debug "[SocketMode] Raw message received: #{msg.data&.truncate(200) || '(nil)'}"
219+
209220
# Skip nil, empty, or non-JSON data (like WebSocket ping/pong frames)
210221
return if msg.data.nil? || msg.data.empty? || !msg.data.start_with?('{')
211222

0 commit comments

Comments
 (0)