Skip to content

[Bug]:Discord WebSocket closes (1006) simultaneously with Telegram getUpdates stalls — isolation not working in 2026.5.28 #88728

Closed as not planned

Description

@berserkerlulubot

Bug type

Crash (process/app exits or hangs)

Beta release blocker

No

Summary

Every ~15-16 minutes, Telegram polling stalls and triggers a restart. At the exact same timestamp, all 3 Discord bots
drop with websocket close code 1006. This happens consistently — the timing is not coincidental.

Steps to reproduce

Outage on multiple applications for communication

Expected behavior

Per the 2026.5.28 release notes, channels should poll independently. Telegram stalls should not affect Discord
connections.

Actual behavior

Discord websockets close (1006) at the precise moment Telegram stall is detected and restarts.

OpenClaw version

2026.5.28

Operating system

macOS 26.5 (arm64)

Install method

npm global

Model

claude sonnet 4.6

Provider / routing chain

openclaw->openrouter->anthropic claude sonnet 4.6

Additional provider/model setup details

Config: 2 Telegram bots, 3 Discord bots, all on the same gateway instance.

Logs, screenshots, and evidence

- 11:16:29 MDT — Telegram stall detected (getUpdates stuck 981s)                                                      
  - 11:16:29 MDT — discord gateway: Gateway websocket closed: 1006 (×3 accounts)                                        
                                                                                                                        
  - 11:23:57 MDT — Telegram stall detected (getUpdates stuck 415s)                                                      
  - 11:23:57 MDT — discord gateway: Gateway websocket closed: 1006 (×3 accounts)

Impact and severity

No response

Additional information

No response

Activity

  1. clawsweeper commented on May 31, 2026

    @clawsweeper
    Contributor

    Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

    Close as duplicate/superseded. Current main has Telegram worker-thread ingress and per-account channel restart scoping, while the remaining code-owned gap is Discord gateway/heartbeat ingress still running on the main event loop, which is already tracked by #83591.

    Canonical path: Use #83591 as the canonical design and fix path for Discord ingress/heartbeat isolation, while leaving Telegram restart-policy work to its existing merged and follow-up trackers.

    So I’m closing this here and keeping the remaining discussion on #83591.

    Review details

    Best possible solution:

    Use #83591 as the canonical design and fix path for Discord ingress/heartbeat isolation, while leaving Telegram restart-policy work to its existing merged and follow-up trackers.

    Do we have a high-confidence way to reproduce the issue?

    No high-confidence live reproduction was run. The source and production timestamps support a plausible main-loop coupling, but the exact synchronized Telegram/Discord outage has not been reproduced on current main in this read-only review.

    Is this the best way to solve the issue?

    No as a standalone tracker. The maintainable solution is to land a maintainer-approved Discord ingress/heartbeat isolation design in the canonical Discord issue, while keeping this issue’s timing logs as supporting evidence.

    Security review:

    Security review: No patch is under review, and this issue is not itself security-sensitive.

    AGENTS.md: found and applied where relevant.

    What I checked:

    • Repository policy read: Root and scoped channel/gateway/extension AGENTS.md files were read and applied to this channel/runtime triage. (AGENTS.md:1, b3f315461ba7)
    • Vision fit: VISION.md prioritizes bug fixes, stability, and improved major messaging channels, so the underlying reliability work belongs in the project but can be tracked canonically elsewhere. (VISION.md:21, b3f315461ba7)
    • Issue evidence: The report provides two timestamp pairs where Telegram getUpdates stalls and all three Discord gateway sockets close with 1006, plus a comment diagnosing main-event-loop starvation as the likely shared cause.
    • Telegram ingress isolation on main: Current Telegram polling uses createTelegramIngressWorker, which starts telegram-ingress-worker.runtime.js through node:worker_threads. (extensions/telegram/src/telegram-ingress-worker.ts:87, b3f315461ba7)
    • Telegram stall handling on main: Current Telegram isolated polling starts the worker, tracks getUpdates liveness, marks the transport dirty on stall, and requests only the Telegram ingress restart cycle. (extensions/telegram/src/polling-session.ts:934, b3f315461ba7)
    • Channel restart scoping on main: The health monitor keys restart records by channelId:accountId and stops/starts the specific account being marked unhealthy. (src/gateway/channel-health-monitor.ts:97, b3f315461ba7)

    Likely related people:

    • steipete: Commit 6c3e767 centralized Discord gateway supervision in the lifecycle file directly adjacent to the remaining Discord isolation gap. (role: recent Discord gateway contributor; confidence: medium; commits: 6c3e767289f9; files: extensions/discord/src/monitor/provider.lifecycle.ts)
    • joshavant: Commit fd244fd added the Telegram worker/spool isolation pattern that the canonical Discord issue asks to mirror. (role: adjacent Telegram isolation pattern owner; confidence: medium; commits: fd244fd76de3; files: extensions/telegram/src/polling-session.ts, extensions/telegram/src/telegram-ingress-worker.ts, extensions/telegram/src/telegram-ingress-worker.runtime.ts)
    • vincentkoc: Commit 01d49cf touched Discord inbound retry and message handling paths adjacent to durable ingress and pickup semantics. (role: recent Discord message-path contributor; confidence: medium; commits: 01d49cf32fb1; files: extensions/discord/src/monitor/message-handler.ts, extensions/discord/src/monitor/inbound-dedupe.ts, extensions/discord/src/monitor/inbound-job.ts)
    • TurboTheTurtle: Commit 31828af hardened Telegram polling restart storms from the same 2026.5.28 era, which separates the Telegram-side fix from the remaining Discord isolation work. (role: recent Telegram polling recovery contributor; confidence: high; commits: 31828af1990e; files: extensions/telegram/src/polling-session.ts, extensions/telegram/src/polling-session.test.ts)

    Codex review notes: model internal, reasoning high; reviewed against b3f315461ba7.

  2. added
    P1High-priority user-facing bug, regression, or broken workflow.
    impact:crash-loopCrash, hang, restart loop, or process-level availability failure.
    impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.
    issue-rating: 🦐 gold shrimpDecent issue quality, but reproduction details are still incomplete.
    clawsweeper:needs-infoClawSweeper needs more reporter information before it can verify this issue.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.
    clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.
    on May 31, 2026
  3. abhinas90 commented on May 31, 2026

    @abhinas90

    I've diagnosed this exact failure mode on a multi-channel OpenClaw gateway. The simultaneous Discord 1006 + Telegram stall at the same second isn't coincidence — it's a single-threaded event loop starvation.

    Root cause: The Telegram getUpdates long-poll (~30s timeout) and Discord gateway WebSocket heartbeat share the same Node.js event loop. When Telegram polling stalls (stuck HTTP request), it blocks the tick that Discord's WebSocket needs to send its heartbeat ACK. Discord interprets the missed heartbeat as a dead connection → close code 1006. The restart cascades because the gateway's onClose handler for both channels fires in the same microtask queue.

    Diagnostic matrix:

    1. Isolation verification — Check if the 2026.5.28 release actually spawned separate child processes for channel polling, or just separate async contexts in the same process. Run: ps aux | grep openclaw — if you see only one process, isolation is async-only, not process-level.

    2. Telegram timeout tuning — The 981s / 415s stall durations suggest the Telegram getUpdates timeout is being extended by something (network blip, upstream Telegram API slowdown). Try setting TELEGRAM_POLL_TIMEOUT=10 in the gateway env — shorter timeouts fail faster and let the event loop breathe.

    3. Heartbeat gap — Discord requires a heartbeat every heartbeat_interval ms (typically 41250). If the event loop is blocked for >41s, you'll 1006. The fix is to run Discord connections in a worker thread (worker_threads) or separate process, not on the main gateway thread.

    4. Quick mitigation — Drop to 2 Discord bots + 1 Telegram bot on one gateway. Each additional bot adds a WebSocket that needs heartbeat servicing. The math here is: num_bots * heartbeat_interval < max_event_loop_stall. With 3 Discord + 2 Telegram = 5 connections, a single stall can cascade.

    This is a regression from the pre-5.28 behavior where channels were more isolated. If you can pin to 2026.5.27 until a fix lands, that's your safest path. The clawsweeper:needs-maintainer-review label suggests the team is aware — adding detailed timing logs (heartbeat send/receive timestamps) will help them pinpoint the exact event loop starvation point.

  4. openclaw-barnacle commented on Jun 15, 2026

    @openclaw-barnacle

    This issue has been automatically marked as stale due to inactivity.
    Please add updates or it will be closed.

  5. added
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    and removed
    clawsweeper:needs-infoClawSweeper needs more reporter information before it can verify this issue.
    issue-rating: 🦐 gold shrimpDecent issue quality, but reproduction details are still incomplete.
    on Jun 15, 2026
  6. locked as resolved and limited conversation to collaborators on Jun 25, 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

    P1High-priority user-facing bug, regression, or broken workflow.bugSomething isn't workingbug:crashProcess/app exits unexpectedly or hangsclawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:crash-loopCrash, hang, restart loop, or process-level availability failure.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.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