openclaw - 💡(How to fix) Fix Discord health-monitor restart crashes gateway with Max reconnect attempts (0) reached [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#56184Fetched 2026-04-08 01:43:55
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

On Windows, OpenClaw 2026.3.24 crashes the entire gateway when the Discord health monitor tries to restart a stale Discord socket. The crash appears to come from the Discord provider''s intentional disconnect path setting reconnect attempts to 0, then still passing through the normal websocket close handler.

Error Message

  1. Discord health monitor decides the provider has a stale socket.
  2. OpenClaw logs a Discord restart for stale-socket.
  3. The process then throws an uncaught exception and the whole gateway exits.

Root Cause

Likely root cause

Fix Action

Fix / Workaround

Local workaround

RAW_BUFFERClick to expand / collapse

Summary

On Windows, OpenClaw 2026.3.24 crashes the entire gateway when the Discord health monitor tries to restart a stale Discord socket. The crash appears to come from the Discord provider''s intentional disconnect path setting reconnect attempts to 0, then still passing through the normal websocket close handler.

Environment

  • OpenClaw 2026.3.24
  • Windows
  • Node 24.14.0
  • Gateway launched by Task Scheduler on login

Observed behavior

  1. Discord health monitor decides the provider has a stale socket.
  2. OpenClaw logs a Discord restart for stale-socket.
  3. The process then throws an uncaught exception and the whole gateway exits.

Evidence

  • Log shows the restart trigger at openclaw-2026-03-28.log:372
    • [discord:default] health-monitor: restarting (reason: stale-socket)
  • Log shows the fatal exception immediately after at openclaw-2026-03-28.log:373
    • Uncaught exception: Error: Max reconnect attempts (0) reached after code 1005
  • In the installed Discord provider bundle:
    • provider-CAlWEl41.js:6952 sets gateway.options.reconnect = { maxAttempts: 0 };
    • provider-CAlWEl41.js:6953 calls gateway.disconnect();
    • provider-CAlWEl41.js:3307 still calls this.handleClose(code);
    • provider-CAlWEl41.js:3363 is handleClose(code)

Likely root cause

The provider intentionally disables reconnects before disconnecting, but the websocket close event still goes through the normal reconnect/error path. With maxAttempts: 0, that path treats the close as fatal and throws instead of treating it as an expected shutdown.

Expected behavior

An intentional provider restart or shutdown should not crash the whole gateway.

Suggested fix

  • If reconnect policy is intentionally disabled with maxAttempts === 0, skip the normal reconnect failure path in the websocket close handler.
  • Or mark intentional disconnects and have handleClose() ignore expected closes triggered by restart/shutdown.

Local workaround

Disabled Discord temporarily in openclaw.json so the gateway can stay up.

extent analysis

Fix Plan

To fix the issue, we need to modify the Discord provider's code to handle intentional disconnects without crashing the gateway. Here are the steps:

  • Modify the handleClose() function to check if the reconnect policy is disabled (maxAttempts === 0) and skip the normal reconnect failure path if so.
  • Alternatively, mark intentional disconnects and have handleClose() ignore expected closes triggered by restart/shutdown.

Example code:

// provider-CAlWEl41.js:3363
handleClose(code) {
  if (this.gateway.options.reconnect && this.gateway.options.reconnect.maxAttempts === 0) {
    // Intentional disconnect, skip reconnect failure path
    return;
  }
  // Normal reconnect failure path
  // ...
}

Or:

// provider-CAlWEl41.js:6952
gateway.options.reconnect = { maxAttempts: 0 };
gateway.intentionalDisconnect = true; // Mark intentional disconnect

// provider-CAlWEl41.js:3363
handleClose(code) {
  if (this.gateway.intentionalDisconnect) {
    // Ignore expected close triggered by restart/shutdown
    return;
  }
  // Normal reconnect failure path
  // ...
}

Verification

To verify the fix, restart the Discord provider and check the logs for any crashes or errors. The gateway should stay up and running without crashing.

Extra Tips

  • Make sure to test the fix thoroughly to ensure it works as expected.
  • Consider adding additional logging or monitoring to detect and handle similar issues in the future.
  • Review the Discord provider's code to ensure that intentional disconnects are properly handled in all scenarios.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

An intentional provider restart or shutdown should not crash the whole gateway.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING