Skip to content

Discord health monitor restart crashes gateway: Max reconnect attempts (0) reached #55165

Closed

Description

@tyedyediggy

Description

The Discord health monitor detects stale WebSocket connections and attempts to restart the Discord provider. However, the reconnection logic has max reconnect attempts set to 0, which causes an uncaught exception that crashes the entire gateway process.

Error

[openclaw] 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)

Reproduction

  1. Run gateway with Discord channel enabled and health monitor active (default)
  2. Wait for a Discord WebSocket to go stale (network hiccup, missed heartbeat ACK)
  3. Health monitor detects stale-socket after ~35 minutes and triggers restart
  4. Reconnection immediately fails with Max reconnect attempts (0)
  5. Uncaught exception kills the entire gateway process (all channels, cron, etc.)

Log sequence

[gateway/health-monitor] [discord:default] health-monitor: restarting (reason: stale-socket)
[openclaw] Uncaught exception: Error: Max reconnect attempts (0) reached after code 1005

This cycle repeated multiple times over 24 hours (gateway restarts via Windows Scheduled Task, then crashes again on next stale socket detection).

Expected behavior

The health monitor restart should use a reasonable reconnect attempt limit (e.g., 3-5 attempts with backoff) rather than 0, and the failure should be handled gracefully without crashing the entire gateway.

Workaround

Disabling the Discord health monitor via config patch.

Environment

  • OpenClaw: 2026.3.24 (cff6dc9)
  • Node: v24.13.1
  • OS: Windows 10 (x64)
  • Discord provider: default config

Activity

  1. steipete commented on Mar 26, 2026

    @steipete
    Contributor

    Closing as a duplicate of #54894.

    This matches the same Discord reconnect or abort crash path tracked in #54931 and fixed by PR #55000:

    • Discord gateway lifecycle abort sets reconnect maxAttempts to 0
    • disconnect then emits a synchronous Max reconnect attempts (0) error
    • the error escapes during teardown and crashes the whole gateway

    Keeping the canonical tracking on #54894 plus the fix discussion on #55000.

  2. locked as resolved and limited conversation to collaborators on Mar 29, 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