Bug Description
When the Hermes gateway restarts, Feishu WebSocket connections are dropped but active sessions are NOT properly closed in the session DB. This causes zombie sessions (with ) to accumulate indefinitely.
Every gateway restart produces new zombie sessions. Over time, the DB accumulates dozens of stale sessions.
Environment
- Hermes Agent: Latest (running from NousResearch/hermes-agent)
- Platform: Feishu (WebSocket mode, not webhook)
- Session DB: SQLite at
Steps to Reproduce
- Start Hermes gateway with Feishu WebSocket adapter active
- Send messages — sessions are created normally
- Restart the gateway (e.g., ✓ User service restart requested)
- Check DB: sessions that were active at restart time have and
Expected Behavior
On gateway shutdown, all active sessions should be closed in the session store with .
Actual Behavior
Sessions remain in DB with . These are the symptoms:
- cleans up the WebSocket thread and event loop
- BUT it does NOT call or for any active sessions
- The in also does not close platform sessions when an adapter disconnects
- Result: zombie sessions accumulate across every restart cycle
Root Cause
In , calls for each platform adapter, but:
- The disconnect handler in only cancels internal background tasks and the WebSocket thread
- No call to to mark active sessions as ended
Normal session cleanup paths ( with reason , , ) are bypassed during crash/restart because those paths are only hit through the normal message handling loop.
Session DB Evidence
All properly closed sessions have set (session_reset, compression, session_switch). Zombie sessions always have .
Suggested Fix
In (or in before calling ), close all active sessions for that platform:
Or more generally — the gateway should close all sessions when shutting down, not rely on each platform adapter to do it.
Are you willing to submit a PR?
No — reporting for awareness and tracking.
Bug Description
When the Hermes gateway restarts, Feishu WebSocket connections are dropped but active sessions are NOT properly closed in the session DB. This causes zombie sessions (with ) to accumulate indefinitely.
Every gateway restart produces new zombie sessions. Over time, the DB accumulates dozens of stale sessions.
Environment
Steps to Reproduce
Expected Behavior
On gateway shutdown, all active sessions should be closed in the session store with .
Actual Behavior
Sessions remain in DB with . These are the symptoms:
Root Cause
In , calls for each platform adapter, but:
Normal session cleanup paths ( with reason , , ) are bypassed during crash/restart because those paths are only hit through the normal message handling loop.
Session DB Evidence
All properly closed sessions have set (session_reset, compression, session_switch). Zombie sessions always have .
Suggested Fix
In (or in before calling ), close all active sessions for that platform:
Or more generally — the gateway should close all sessions when shutting down, not rely on each platform adapter to do it.
Are you willing to submit a PR?
No — reporting for awareness and tracking.