Skip to content

[Bug]: Uncaught exception: Error: Max reconnect attempts (0) reached after code 1006 at GatewayPlugin.handleReconnectionAttempt #36055

Closed
echoVic/openclaw
#4

Description

@perinst

Bug type

Crash (process/app exits or hangs)

Summary

18:49:51 [openclaw] Uncaught exception: Error: Max reconnect attempts (0) reached after code 1006
    at GatewayPlugin.handleReconnectionAttempt (file:///C:/Users/phanm/AppData/Roaming/nvm/v22.17.1/node_modules/openclaw/node_modules/@buape/carbon/src/plugins/gateway/GatewayPlugin.ts:400:5)
    at GatewayPlugin.handleClose (file:///C:/Users/phanm/AppData/Roaming/nvm/v22.17.1/node_modules/openclaw/node_modules/@buape/carbon/src/plugins/gateway/GatewayPlugin.ts:466:8)
    at WebSocket.<anonymous> (file:///C:/Users/phanm/AppData/Roaming/nvm/v22.17.1/node_modules/openclaw/node_modules/@buape/carbon/src/plugins/gateway/GatewayPlugin.ts:376:9)
    at WebSocket.emit (node:events:518:28)
    at WebSocket.emitClose (C:\Users\phanm\AppData\Roaming\nvm\v22.17.1\node_modules\openclaw\node_modules\ws\lib\websocket.js:263:12)
    at emitErrorAndClose (C:\Users\phanm\AppData\Roaming\nvm\v22.17.1\node_modules\openclaw\node_modules\ws\lib\websocket.js:1047:13)
    at processTicksAndRejections (node:internal/process/task_queues:90:21)

Steps to reproduce

  1. Setting new token bot for discord channel file openclaw.json

Expected behavior

Reload config instead of crash app for over maximum configuration of attempt reload

Actual behavior

Show logs I pass above and gateway crash

OpenClaw version

2026.3.1

Operating system

Windows 11

Install method

npm global

Logs, screenshots, and evidence

Impact and severity

Affected : discord

Additional information

No response

Activity

  1. added
    bug
    on Mar 5, 2026
  2. added
    bug:crash
    on Mar 5, 2026
  3. Octane0411 commented on Mar 5, 2026

    @Octane0411
    Contributor

    Submitted a fix in #36159.

    Root Cause

    • Discord GatewayPlugin handleReconnectionAttempt threw uncaught exception when max reconnect attempts reached, crashing the gateway

    Fix

    • Added withReconnectionErrorHandling() wrapper that catches errors and emits gateway error events instead of throwing

    Verification

    • Configure Discord with invalid token to trigger max reconnect attempts; verify gateway logs error but does not crash
  4. kkellyoffical commented on Mar 9, 2026

    @kkellyoffical

    I hit what looks like the same crash class on macOS, but in a different trigger path, and it still happened for me on 2026.3.7.

    Environment:

    • OpenClaw 2026.3.7
    • macOS 26.3 (arm64)
    • install method: npm global + OpenClaw.app installed
    • Discord enabled as a critical remote channel
    • Discord configured with an explicit local proxy (channels.discord.proxy = http://127.0.0.1:7897) while the machine was also using Clash Verge TUN

    What happened:

    • Discord started failing with transient network/proxy/TLS errors rather than an obviously bad token
    • I saw repeated log lines like:
      • Failed to get gateway information from Discord: fetch failed
      • failed to deploy native commands: fetch failed
      • failed to fetch bot identity: TypeError: fetch failed
      • gateway error: Error: Client network socket disconnected before secure TLS connection was established
    • Then the gateway hit the uncaught reconnect path and exited:
      • Uncaught exception: Error: Max reconnect attempts (0) reached after code 1006

    Observed impact:

    • ai.openclaw.gateway LaunchAgent stopped
    • ai.openclaw.node then also stopped because it could no longer connect to local gateway 127.0.0.1:18789
    • OpenClaw.app stayed open, but openclaw status showed gateway unreachable and both services stopped

    Recovery:

    • Manual openclaw gateway restart
    • Manual openclaw node restart
    • After restart, openclaw channels status --probe returned Discord connected again

    Why this might be useful:

    • This was not a stable misconfiguration like an invalid token. The same config later recovered and connected successfully.
    • So this seems to confirm that transient Discord/network failures can still escalate into a process-level gateway exit on a current release, at least in this proxy/TUN setup.

    If helpful, I can also provide the exact log snippet sequence with timestamps from my local gateway.err.log / node.err.log.

  5. steipete commented on Mar 25, 2026

    @steipete
    Contributor

    Closing as duplicate of #54182, merged on March 25, 2026. That fix keeps the Discord 1006 reconnect failure from surfacing as an uncaught exception that crashes the gateway.

  6. locked as resolved and limited conversation to collaborators on Mar 28, 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

    bugbug:crash

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions