Bug Report
OpenClaw version: 2026.3.2
OS: macOS 26.3.0 (arm64, Mac mini M4)
Gateway mode: local
Description
When an agent session takes a long time to process a Discord message (e.g., complex tool calls, heavy context loading), the DiscordMessageListener blocks for 300+ seconds. This causes Discord's gateway to drop the WebSocket connection (code 1006), which triggers cascading failures:
- Slow listener detected (329.5s for MESSAGE_CREATE)
- WebSocket closes with code 1006
- Resume attempts fail or succeed briefly before repeating
- Health monitor detects "stuck" state and restarts the provider
- Restart sometimes fails with
fetch failed errors
- Gateway becomes unresponsive until manual restart
Log Evidence
12:41:43 [discord] Slow listener detected: DiscordMessageListener took 329.5 seconds for event MESSAGE_CREATE
13:06:07 [discord] gateway: WebSocket connection closed with code 1006
13:06:07 [discord] gateway: Attempting resume with backoff: 1000ms after code 1006
...
[health-monitor] [discord:default] health-monitor: restarting (reason: stuck)
[discord] channel resolve failed; using config entries. fetch failed
[discord] discord: failed to deploy native commands: fetch failed
[openclaw] Unhandled promise rejection: Error: Failed to get gateway information from Discord
Root Cause Hypothesis
The message listener appears to be synchronous/blocking — it waits for the full agent response before returning control to the gateway event loop. Discord requires a heartbeat ACK within ~41.25 seconds (their heartbeat interval). A 329-second block guarantees missed heartbeats → connection drop.
Suggested Fix
Process Discord messages asynchronously — acknowledge the gateway event immediately, then handle the agent response in a separate async context. The listener should never block the heartbeat loop.
Workaround
We currently treat Discord as output-only (alerts, digests) and route all real conversations through webchat, which avoids long processing times on the Discord gateway.
Related
Additional Context
This consistently reproduces when the agent has heavy context (large MEMORY.md, multiple tool calls, image processing). Shorter responses (~5-10s) do not trigger the issue.
Bug Report
OpenClaw version: 2026.3.2
OS: macOS 26.3.0 (arm64, Mac mini M4)
Gateway mode: local
Description
When an agent session takes a long time to process a Discord message (e.g., complex tool calls, heavy context loading), the
DiscordMessageListenerblocks for 300+ seconds. This causes Discord's gateway to drop the WebSocket connection (code 1006), which triggers cascading failures:fetch failederrorsLog Evidence
Root Cause Hypothesis
The message listener appears to be synchronous/blocking — it waits for the full agent response before returning control to the gateway event loop. Discord requires a heartbeat ACK within ~41.25 seconds (their heartbeat interval). A 329-second block guarantees missed heartbeats → connection drop.
Suggested Fix
Process Discord messages asynchronously — acknowledge the gateway event immediately, then handle the agent response in a separate async context. The listener should never block the heartbeat loop.
Workaround
We currently treat Discord as output-only (alerts, digests) and route all real conversations through webchat, which avoids long processing times on the Discord gateway.
Related
Additional Context
This consistently reproduces when the agent has heavy context (large MEMORY.md, multiple tool calls, image processing). Shorter responses (~5-10s) do not trigger the issue.