hermes - 💡(How to fix) Fix fix(gateway): WeCom gateway CPU spin when WebSocket enters CLOSING state [2 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

  • aiohttp.WSMsgType.ERROR
  1. Gateway logs show no error, but process is spinning

Root Cause

The elif branch checking for terminal WebSocket states only includes:

  • aiohttp.WSMsgType.CLOSE
  • aiohttp.WSMsgType.CLOSED
  • aiohttp.WSMsgType.ERROR

It is missing aiohttp.WSMsgType.CLOSING.

Fix Action

Fixed

RAW_BUFFERClick to expand / collapse

Bug Description

When the WeCom (WeWork) WebSocket connection enters WSMsgType.CLOSING state (e.g., during network interruption or server-side close), the _read_events() loop in gateway/platforms/wecom.py does not handle this message type. This causes receive() to immediately return CLOSING again, resulting in a tight loop that consumes 45-100% CPU.

Root Cause

The elif branch checking for terminal WebSocket states only includes:

  • aiohttp.WSMsgType.CLOSE
  • aiohttp.WSMsgType.CLOSED
  • aiohttp.WSMsgType.ERROR

It is missing aiohttp.WSMsgType.CLOSING.

Environment

  • Python 3.11+
  • aiohttp (any version with WSMsgType.CLOSING)
  • Hermes Agent main branch

Reproduction Steps

  1. Start gateway with WeCom platform enabled: hermes gateway run
  2. Trigger a network interruption or wait for server-side close
  3. Observe CPU usage spike to 45-100% in hermes_cli.main gateway run process
  4. Gateway logs show no error, but process is spinning

Expected Behavior

Gateway should recognize CLOSING as a terminal state, close the connection gracefully, and reconnect.

Actual Behavior

CPU spins at 45-100% until process is manually killed.

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

hermes - 💡(How to fix) Fix fix(gateway): WeCom gateway CPU spin when WebSocket enters CLOSING state [2 pull requests]