Skip to content

Gateway crashes on WebSocket reconnection (Discord/Slack) instead of retrying #55109

Closed

Description

@marcelofpfelix

Problem

When WebSocket connections (Discord or Slack) encounter errors, the gateway crashes with an uncaught exception instead of reconnecting gracefully.

Error

[openclaw] Uncaught exception: Error: Max reconnect attempts (0) reached after code 1005
    at SafeGatewayPlugin.handleReconnectionAttempt (file:///opt/homebrew/lib/node_modules/openclaw/dist/provider-CAlWEl41.js:3318:47)
    at SafeGatewayPlugin.handleClose (file:///opt/homebrew/lib/node_modules/openclaw/dist/provider-CAlWEl41.js:3364:8)

Sequence (Discord example)

10:23:05.242 [health-monitor] [discord:default] restarting (reason: stale-socket)
10:23:05.358 [openclaw] Uncaught exception: Max reconnect attempts (0)

The health monitor detects a stale socket and triggers a restart, but the WebSocket handler immediately fails with maxReconnectAttempts=0.

Impact

  • 236 Discord stale-socket restarts observed
  • 253 gateway restarts in a single day (2026-03-24)
  • Intermittent service disruption
  • Cron jobs fail during crashes

Root Cause

SafeGatewayPlugin.handleReconnectionAttempt has maxReconnectAttempts set to 0, meaning it fails immediately on WebSocket close instead of retrying with backoff.

Proposed Fix

Add config options for WebSocket reconnection behavior, with sensible defaults:

{
  "channels": {
    "discord": {
      "reconnect": {
        "maxAttempts": 10,
        "initialDelayMs": 1000,
        "maxDelayMs": 30000
      }
    },
    "slack": {
      "socketMode": {
        "maxReconnectAttempts": 10
      }
    }
  }
}

Or set a sensible default (e.g., 10 attempts with exponential backoff) instead of 0.

Environment

  • OpenClaw: 2026.3.24
  • OS: macOS 26.3.1 (arm64)
  • Node: 25.8.2

Activity

  1. changed the title [-]Slack Socket Mode: gateway crashes on WebSocket errors instead of reconnecting[/-] [+]Gateway crashes on WebSocket reconnection (Discord/Slack) instead of retrying[/+] on Mar 26, 2026
  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