Skip to content

[Bug]: Discord channel connection failure causes gateway infinite restart loop #34592

Description

@yjfkpyu

Summary

When the Discord API is unreachable (e.g., due to network restrictions or no proxy/TUN mode enabled), the gateway process crashes into an infinite restart loop due to unhandled promise rejections in GatewayPlugin.registerClient. This kills the entire gateway, affecting all channels (including Telegram which is working fine) and all agents.

Steps to reproduce

  1. Configure OpenClaw with Discord channel enabled
  2. Ensure Discord API (discord.com) is unreachable from the host (e.g., no proxy/TUN mode in regions where Discord is blocked)
  3. Start or restart the gateway: openclaw gateway restart
  4. Observe the gateway crash and restart every ~3 seconds

Expected behavior

  • The Discord channel should be marked as disconnected / error state
  • The gateway process should remain alive and healthy
  • Other channels (Telegram, etc.) and agents should continue working normally
  • Retry with exponential backoff instead of immediate crash-restart cycles

Actual behavior

The gateway crashes every ~3 seconds due to unhandled promise rejections:

Error log (~/.openclaw/logs/gateway.err.log):

[openclaw] Unhandled promise rejection: Error: Failed to get gateway information from Discord: fetch failed
    at GatewayPlugin.registerClient (file:///opt/homebrew/lib/node_modules/openclaw/node_modules/@buape/carbon/src/plugins/gateway/GatewayPlugin.ts:114:11)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)
[discord] failed to deploy native commands: fetch failed
[discord] failed to fetch bot identity: TypeError: fetch failed

Gateway log shows rapid PID changes (crash-restart loop):

[gateway] listening on ws://127.0.0.1:18800 (PID 99204)
[gateway] listening on ws://127.0.0.1:18800 (PID 99243)   # ~3s later
[gateway] listening on ws://127.0.0.1:18800 (PID 99272)   # ~3s later
[gateway] listening on ws://127.0.0.1:18800 (PID 99302)   # ~3s later

Environment

  • OpenClaw: 2026.3.2 (stable)
  • OS: macOS 26.3 (arm64)
  • Node: 23.11.0
  • Install method: npm (homebrew)

Suggested fix

The GatewayPlugin.registerClient call (and related Discord fetch operations) should be wrapped in try/catch with proper error handling. A single channel's connection failure should never crash the entire gateway process.

Related issues: #23441, #21082, #12354 (all describe similar unhandled rejection → gateway crash patterns for different triggers)

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleMarked as stale due to inactivity

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions