← Back to library

Discord 自发消息回流风暴:在入口短路 bot-own MESSAGE_CREATE

场景:cron 向 Discord 发消息后被监听器回收并再次走完整处理链,导致 slow listener、WS 掉线。技巧:在事件入口提前过滤 bot 自身消息并做心跳隔离。

GITHUBDiscovered 2026-02-14Author aronchick
Prerequisites
  • Discord channel integration is enabled and bot can post scheduled/cron messages.
  • Gateway logs can be inspected for slow-listener and WebSocket close codes.
Steps
  1. Establish baseline: collect 24h counts for slow listener warnings, WS 1005/1006 disconnects, and no-reply events.
  2. Add early guard in Discord MESSAGE_CREATE handler to drop events where `message.author.id === bot.user.id` before session/pipeline creation.
  3. Keep `requireMention`/channel routing as a secondary control, not the primary self-loop fix.
  4. Re-run the same 24h metrics and compare reduction in listener latency and reconnect frequency.
Commands
openclaw gateway status
openclaw logs --local-time
openclaw gateway restart
Verify

Bot outbound messages no longer create long-running self-processing events, and WS disconnect frequency drops materially.

Caveats
  • This is based on production issue analysis, not yet a released universal fix(需验证).
  • If you rely on bot echoes for audit workflows, define an explicit alternative logging path before filtering.
Source attribution

This tip is aggregated from community/public sources and preserved with attribution.

Open original source ↗
Visit original post