Skip to content

Discord stale-socket recovery crashes gateway with Max reconnect attempts (0) reached after code 1005 #55296

Closed

Description

@buttheadus

Bug type

Crash (process/app exits or hangs)

Beta release blocker

No

Summary

Summary

When the Discord channel socket goes stale, OpenClaw's health monitor attempts to recover it, but the Discord reconnect path throws an uncaught exception and crashes the entire gateway process.

Version / Environment

  • OpenClaw: 2026.3.24
  • Channel: stable
  • Install: pnpm
  • OS: Windows 10.0.26200
  • Gateway mode: local
  • Gateway bind: loopback
  • Discord: enabled
  • Telegram: enabled

openclaw update status reports the install is already up to date on stable.

Observed behavior

The gateway runs normally until Discord hits a stale socket condition.

Then logs show:

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

After that, the gateway process dies and is restarted externally by the Windows scheduled task.

Expected behavior

A stale Discord socket should be recoverable and should not crash the entire gateway process.

At worst:

  • Discord should reconnect or fail its own channel runtime cleanly
  • the gateway should stay alive
  • channel restart failures should be contained, not become uncaught process-level exceptions

Why this seems like a bug

I checked local config and did not find any Discord reconnect setting that would set max attempts to 0.

I also inspected the installed bundle and found what appears to be a nonzero reconnect configuration in the Discord gateway plugin path, including:

  • reconnect: { maxAttempts: 50 }

But at runtime the thrown error is:

  • Max reconnect attempts (0) reached after code 1005

So it looks like either:

  1. the reconnect options are being lost before they reach the Discord gateway client, or
  2. a stale-socket / restart path is constructing the reconnect handler incorrectly

Relevant log lines

[discord:default] health-monitor: restarting (reason: stale-socket)
Uncaught exception: Error: Max reconnect attempts (0) reached after code 1005
at SafeGatewayPlugin.handleReconnectionAttempt (...)
at SafeGatewayPlugin.handleClose (...)

### Steps to reproduce

## Summary

When the Discord channel socket goes stale, OpenClaw's health monitor attempts to recover it, but the Discord reconnect path throws an uncaught exception and crashes the entire gateway process.

## Version / Environment

- OpenClaw: `2026.3.24`
- Channel: `stable`
- Install: `pnpm`
- OS: Windows 10.0.26200
- Gateway mode: local
- Gateway bind: loopback
- Discord: enabled
- Telegram: enabled

`openclaw update status` reports the install is already up to date on stable.

## Observed behavior

The gateway runs normally until Discord hits a stale socket condition.

Then logs show:

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

After that, the gateway process dies and is restarted externally by the Windows scheduled task.

## Expected behavior

A stale Discord socket should be recoverable and should not crash the entire gateway process.

At worst:
- Discord should reconnect or fail its own channel runtime cleanly
- the gateway should stay alive
- channel restart failures should be contained, not become uncaught process-level exceptions

## Why this seems like a bug

I checked local config and did not find any Discord reconnect setting that would set max attempts to `0`.

I also inspected the installed bundle and found what appears to be a nonzero reconnect configuration in the Discord gateway plugin path, including:
- `reconnect: { maxAttempts: 50 }`

But at runtime the thrown error is:
- `Max reconnect attempts (0) reached after code 1005`

So it looks like either:
1. the reconnect options are being lost before they reach the Discord gateway client, or
2. a stale-socket / restart path is constructing the reconnect handler incorrectly

## Relevant log lines

```text
[discord:default] health-monitor: restarting (reason: stale-socket)
Uncaught exception: Error: Max reconnect attempts (0) reached after code 1005
at SafeGatewayPlugin.handleReconnectionAttempt (...)
at SafeGatewayPlugin.handleClose (...)

### Expected behavior

stay signed into discord

### Actual behavior

bad socket causes an error and closes the entire openclaw gateway

### OpenClaw version

OpenClaw version: **2026.3.24**  Also: - Channel: **stable** - Install: **pnpm**

### Operating system

windows 11

### Install method

_No response_

### Model

openai-codex/gpt-5.4

### Provider / routing chain

openclaw-control-ui -> local OpenClaw gateway (ws://127.0.0.1:18789) -> Discord provider -> Discord gateway WebSocket

### Additional provider/model setup details

_No response_

### Logs, screenshots, and evidence

```shell

Impact and severity

No response

Additional information

No response

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. buttheadus commented on Mar 29, 2026

    @buttheadus
    Author

    Works great now, thanks.

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