Skip to content

[Bug]: Discord health-monitor stale-socket restart triggers uncaught exception, crashes gateway process #55260

Closed

Description

@Paul-le-cimanova

Bug type

Crash (process/app exits or hangs)

Beta release blocker

No

Summary

Discord health-monitor detects stale-socket, force-stops the gateway with reconnect.maxAttempts = 0, which throws an uncaught Max reconnect attempts (0) reached after code 1005 error that kills the entire gateway process.

Steps to reproduce

  1. Run OpenClaw 2026.3.24 with Discord provider enabled and health-monitor active (default 300s interval)
  2. Configure a guild with multiple channel bindings
  3. Wait 25-40 minutes — the health-monitor detects a stale Discord WebSocket
  4. Observe the gateway crashes with exit code 1 instead of restarting gracefully

Expected behavior

The health-monitor's force-stop should cleanly shut down or the gateway supervisor should catch the reconnect error and recover without crashing the process. The v2026.3.24 release note "Discord/gateway supervision: centralize gateway error handling" suggests this was the intent.

Actual behavior

Uncaught exception: Error: Max reconnect attempts (0) reached after code 1005 — gateway exits with status 1, systemd restarts the entire process.

OpenClaw version

2026.3.24 (cff6dc9)

Operating system

Ubuntu 22.04 (Hetzner VPS, Linux 5.15.0-173-generic x64)

Install method

npm global

Model

GLM-5 Turbo (zai/glm-5-turbo)

Provider / routing chain

openclaw -> zai/glm-5-turbo (issue is Discord provider-side, not model-dependent)

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Mar 26 15:40:41 vps-openclaw [health-monitor] [discord:default] health-monitor: restarting (reason: stale-socket)
Mar 26 15:40:41 vps-openclaw [openclaw] Uncaught exception: Error: Max reconnect attempts (0) reached after code 1005
Mar 26 15:40:41 vps-openclaw systemd[1]: openclaw-gateway.service: Main process exited, code=exited, status=1/FAILURE
Mar 26 15:40:41 vps-openclaw systemd[1]: openclaw-gateway.service: Failed with result 'exit-code'.
Mar 26 15:40:46 vps-openclaw systemd[1]: Scheduled restart job, restart counter is at 11.


Pattern repeats every 25-40 minutes. 8 occurrences in 6 hours. Network to Discord is stable (0% packet loss, 0.5ms avg latency).

Source code reference — provider-CAlWEl41.js ~line 6952:
gateway.options.reconnect = { maxAttempts: 0 };
gateway.disconnect();

The health-monitor's abort handler intentionally sets maxAttempts to 0 before disconnecting, but the resulting error from discord.js propagates as uncaught.

Impact and severity

  • Affected: Any deployment using Discord provider with health-monitor enabled
  • Severity: High (gateway crash-loop every ~35 minutes)
  • Frequency: Always (8/8 cycles in 6 hours observed)
  • Consequence: All channel providers restart, agent sessions interrupted, in-flight messages lost

Additional information

Last known good behavior unknown — first observed on 2026.3.24. The v2026.3.24 release included a fix for "Discord/gateway supervision" but the health-monitor's force-stop error path still bypasses the supervisor. No workaround available beyond disabling health-monitor or patching the disconnect logic.

Activity

  1. added
    bug
    on Mar 26, 2026
  2. joelnishanth commented on Mar 26, 2026

    @joelnishanth
    Contributor

    This is a duplicate of #55274. Fix tracked in #55324 — root cause is that gatewaySupervisor.dispose() removes the error listener before Carbon finishes emitting the reconnect-exhausted event, causing an uncaught exception.

    — Joel Nishanth · offlyn.AI

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

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

    bug

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions