hermes - 💡(How to fix) Fix [Bug]: QQBot closed WebSocket 导致无限空循环,单线程 CPU 100% [1 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

Additional Logs / Traceback (optional)

Root Cause

Root Cause Analysis (optional)

Fix Action

Fixed

Code Example


---
RAW_BUFFERClick to expand / collapse

Bug Description

问题描述

当 QQBot 的 WebSocket 连接断开(常见 Session timed out code=4009)后,adapter 进入 busy loop。

额外信息

  • 我用只读栈转储确认了主线程位置
  • 类似问题已存在 #19821、#25505 等

Steps to Reproduce

复现步骤

  1. 正常启动 Hermes gateway 并启用 QQBot
  2. 等待一段时间(或网络波动/超时)
  3. 出现日志:WebSocket closed: code=4009 reason=Session timed outReconnect failed
  4. 之后 CPU 持续 100%(macOS 上特别明显)

Expected Behavior

预期行为

连接断开后应正确触发重连逻辑,或在失败后退出循环并清理,而不是 CPU 空转。

Actual Behavior

实际行为

  • 线程卡在 gateway/platforms/qqbot/adapter.py:492await self._read_events()
  • _read_events() 的 while 条件 while self._running and self._ws and not self._ws.closed_ws 已关闭时直接返回
  • _listen_loop() 立即进入下一轮,无 sleep、无异常、无重连 → 忙等待

Affected Component

Gateway (Telegram/Discord/Slack/WhatsApp), Other

Messaging Platform (if gateway-related)

No response

Debug Report

Operating System

macOS 15.2

Python Version

No response

Hermes Version

No response

Additional Logs / Traceback (optional)

Root Cause Analysis (optional)

No response

Proposed Fix (optional)

No response

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING