Skip to content

[Bug]: Gateway crashes with uncaught exception on Discord WebSocket stale-socket reconnect (code 1005) #57291

Description

@jknau29-creator

Bug type

Crash (process/app exits or hangs)

Beta release blocker

No

Summary

The gateway process crashes with an uncaught exception repeatedly (~every 90 minutes) when the internal health monitor detects a stale Discord socket and attempts to restart it. Instead of recovering gracefully, the reconnect failure propagates as an uncaught exception and kills the entire Node.js process.

Steps to reproduce

Running normally with a Discord channel connected. No special config required — happens on its own at regular intervals.

Log Sequence

  1. Health monitor fires:
    health-monitor: restarting (reason: stale-socket)
  2. Uncaught exception immediately follows and process exits:

```
[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. (provider-CAlWEl41.js:3307:9)
at WebSocket.emit (node:events:508:28)
at WebSocket.emitClose (...ws/lib/websocket.js:273:10)
at TLSSocket.socketOnClose (...ws/lib/websocket.js:1346:15)
```

Expected behavior

Health monitor restarts the Discord WebSocket connection and gateway continues running.

Actual behavior

Uncaught exception kills the gateway process entirely. Crashed 4+ times today.

OpenClaw version

2026.3.24

Operating system

Windows 11 x64 (Build 26200)

Install method

npm global

Model

anthropic/claude-sonnet-4-6 (primary), ollama/qwen2.5:7b (cron jobs at time of crash)

Provider / routing chain

openclaw -> anthropic (direct, no proxy or AI gateway)

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingbug:crashProcess/app exits unexpectedly or hangs

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions