Skip to content

[Bug]: Channel WebSocket abnormal closure (Discord + Telegram) crashes entire gateway process #56057

Closed

Description

@robbied90-blip

Bug type

Crash (process/app exits or hangs)

Beta release blocker

No

Summary

A transient DNS failure (Discord) or Telegram polling stall causes an abnormal WebSocket closure that throws an uncaught exception and kills the entire gateway process. Reproduced repeatedly across both channels on the same day.

Steps to reproduce

Run OpenClaw 2026.3.24 on Windows with Discord channel enabled
Experience any brief DNS failure or network blip affecting gateway.discord.gg
The health monitor detects a stale socket and tries to restart the Discord channel
Gateway crashes with uncaught exception — same crash repeats every 5 min (health monitor loop)
Separately: with Telegram enabled and a long-running agent task active, Telegram polling stalls 180s+, gateway then crashes with 1006 abnormal closure

Expected behavior

Channel-level WebSocket failures should be isolated to the channel plugin. The gateway process should stay running with the channel in a degraded/reconnecting state.

Actual behavior

Gateway process dies hard. Observed 7+ crashes in 2 hours from a single DNS blip (Discord). Telegram polling stall produced 3 additional crashes in ~1 hour

OpenClaw version

2026.3.24

Operating system

Windows 10 19045 (x64)

Install method

npm global

Model

anthropic/claude-sonnet-4-6

Provider / routing chain

openclaw -> anthropic

Additional provider/model setup details

No response

Logs, screenshots, and evidence

# Discord crash
discord gateway error: Error: getaddrinfo ENOTFOUND gateway.discord.gg
discord gateway: WebSocket connection closed with code 1006
discord gateway: Reconnecting with backoff: 2000ms after code 1006
discord gateway error: getaddrinfo ENOTFOUND gateway.discord.gg
Uncaught exception: Error: Max reconnect attempts (0) reached after code 1006
  at SafeGatewayPlugin.handleReconnectionAttempt (provider-CAlWEl41.js:3318:47)
  at SafeGatewayPlugin.handleClose (provider-CAlWEl41.js:3364:8)

# Health monitor making it worse (repeating every 5 min)
gateway/health-monitor: [discord:default] health-monitor: restarting (reason: stale-socket)
[same crash repeats]

# Telegram crash
error: Telegram polling stall detected (no getUpdates for 183.69s); forcing restart.
error: Telegram polling runner stopped (polling stall detected); restarting in 2.49s.
[~20 min later]
Error: gateway closed (1006 abnormal closure (no close frame)): no close reason

Impact and severity

Affected: All users running Discord or Telegram channels on Windows
Severity: High — any DNS blip or network hiccup takes down the entire assistant, not just the affected channel
Frequency: Always when triggered — 10+ crashes observed in one session
Consequence: Gateway goes offline, all channels (webchat, Telegram, etc.) become unavailable until manual restart or schtasks recovery

Additional information

Workaround: disable Discord (channels.discord.enabled: false). No clean workaround for Telegram. Both require a Windows Scheduled Task to auto-restart the gateway. The Discord config hot-reload also triggers the crash (disabling Discord via openclaw config set causes the same uncaught exception as the DNS failure).

Activity

  1. added
    bug
    on Mar 27, 2026
  2. steipete commented on Apr 25, 2026

    @steipete
    Contributor

    Closing this as implemented after Codex review.

    Current main already contains the requested crash isolation for Discord/Telegram channel failures, and the relevant implementation appears to have shipped in v2026.4.22.

    What I checked:

    • Discord teardown errors are suppressed instead of escaping: The Discord gateway supervisor classifies emitter errors and explicitly suppresses late teardown/dispose reconnect-exhausted events rather than letting them surface as uncaught process-killing exceptions. (extensions/discord/src/monitor/gateway-supervisor.ts:156, 7130e56f872a)
    • Discord lifecycle owns cleanup and detaches supervisor on shutdown: The Discord lifecycle flips into stopping mode and detaches the supervisor in finally-cleanup, which matches the reported stale-socket/config-reload teardown crash path and keeps shutdown bounded to the channel lifecycle. (extensions/discord/src/monitor/provider.lifecycle.ts:457, 7130e56f872a)
    • Regression tests cover late reconnect-exhausted teardown/dispose events: Tests assert that late reconnect-exhausted Discord gateway errors during teardown or after dispose are logged/suppressed and do not throw. (extensions/discord/src/monitor/gateway-supervisor.test.ts:59, 7130e56f872a)
    • Telegram polling stalls restart locally instead of crashing the gateway: Telegram polling-session watchdog logic marks the transport dirty, stops the runner/bot, and re-enters a restart/backoff cycle; tests cover the stall-triggered restart path. (extensions/telegram/src/polling-session.ts:318, 7130e56f872a)
    • Gateway health monitor isolates restart failures and avoids false Telegram stale-socket restarts: Channel restarts are wrapped in try/catch so restart failures are logged instead of crashing the gateway, and stale-socket checks only apply when a channel reports transport activity timestamps; tests explicitly skip Telegram channels with null transport liveness. (src/gateway/channel-health-monitor.ts:160, 7130e56f872a)
    • Release v2026.4.22 already documents these fixes, and current main has no further diffs in the relevant files: The v2026.4.22 changelog includes Discord gateway shutdown/supervision crash fixes and Telegram polling watchdog/transport fixes. A diff from v2026.4.22 to HEAD over the relevant Discord/Telegram/health-monitor files is empty, so the shipped release already contains the implementation now on main. (CHANGELOG.md:403, 00bd2cf7a376)

    So I’m closing this as already implemented rather than keeping a duplicate issue open.

    Review notes: reviewed against 7130e56f872a; fix evidence: release v2026.4.22, commit 00bd2cf7a376.

  3. locked as resolved and limited conversation to collaborators on Apr 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

    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