Skip to content

Discord gateway crash: maxAttempts resolves to 0, uncaught exception kills process #55367

Closed

Description

@jorgeborbolla

Summary

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.

Environment

  • OpenClaw 2026.3.24 (cff6dc9)
  • macOS (Apple Silicon)
  • Node v22.22.0
  • LaunchAgent service

Activity

  1. gambrill commented on Mar 26, 2026

    @gambrill

    I’m seeing what appears to be the same issue on macOS with Discord enabled.

    Environment:

    • OpenClaw 2026.3.24
    • macOS 26.3

    Observed log pattern:

    • health-monitor: restarting (reason: stale-socket)
    • Error: Max reconnect attempts (0) reached after code 1005

    This 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.

  2. Takhoffman commented on Mar 29, 2026

    @Takhoffman
    Contributor

    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.

  3. locked as resolved and limited conversation to collaborators on Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions