You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Discord gateway crash: maxAttempts resolves to 0, uncaught exception kills process #55367
The Discord WebSocket gateway reconnect logic throws an uncaught exception that kills the entire OpenClaw process when the Discord gateway connection drops. The maxAttempts value resolves to 0 instead of the default 5, so the very first disconnect is fatal.
Error
Uncaught exception: Error: Max reconnect attempts (0) reached after code 1005
at SafeGatewayPlugin.handleReconnectionAttempt (provider-CAlWEl41.js:3318:47)
at SafeGatewayPlugin.handleClose (provider-CAlWEl41.js:3364:8)
at WebSocket.<anonymous> (provider-CAlWEl41.js:3307:9)
Behavior
Discord WebSocket drops with close code 1005 (no status)
handleReconnectionAttempt checks reconnectPolicy.maxAttempts which is 0
Since reconnectAttempts (0) >= maxAttempts (0), it immediately throws
The error is uncaught → process exits
The health monitor detects stale-socket but the process crashes before it can recover
Expected
maxAttempts should default to 5 (as seen in the source: maxAttempts: 5)
Transient Discord disconnects should reconnect with backoff, not crash
Even at max attempts, the error should be caught gracefully (degraded mode, not process exit)
Reproduction
Happens on transient Discord gateway disconnects (code 1005). Observed twice in one day (5:00 AM and 8:33 AM PT). The second crash left the gateway down for ~5 hours until manually restarted.
Workaround
None currently. The reconnect maxAttempts is not exposed as a config option under channels.discord. The channels.discord.retry config only controls outbound API call retries.
Closing as fixed upstream. This crash family was addressed by upstream Discord lifecycle changes merged in #55991, and PR #55000 was closed after the upstream maintainer confirmed the fix landed there.
If you still hit the same Max reconnect attempts (0) / stale-socket gateway crash on the latest OpenClaw release, comment here with fresh logs and version details and we can reopen or spin a new issue.
Activity
gambrill commentedon Mar 26, 2026
I’m seeing what appears to be the same issue on macOS with Discord enabled.
Environment:
Observed log pattern:
health-monitor: restarting (reason: stale-socket)Error: Max reconnect attempts (0) reached after code 1005This repeated multiple times on 2026-03-26, including around 11:39 EDT and 13:49 EDT.
I also ruled out a separate 10-minute cron job that was producing noisy logs but was not causing the actual restarts.
Happy to provide additional redacted logs if useful.
Takhoffman commentedon Mar 29, 2026
Closing as fixed upstream. This crash family was addressed by upstream Discord lifecycle changes merged in #55991, and PR #55000 was closed after the upstream maintainer confirmed the fix landed there.
If you still hit the same
Max reconnect attempts (0)/ stale-socket gateway crash on the latest OpenClaw release, comment here with fresh logs and version details and we can reopen or spin a new issue.