Skip to content

fix(gateway): enforce reconnect contract across adapters - #61767

Merged
teknium1 merged 5 commits into
mainfrom
hermes/hermes-c98ddd2f
Jul 10, 2026
Merged

fix(gateway): enforce reconnect contract across adapters#61767
teknium1 merged 5 commits into
mainfrom
hermes/hermes-c98ddd2f

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

QQ Bot and WeCom Callback now recover through the gateway reconnect watcher, with a repository-wide contract test preventing future adapter signature drift.

The watcher passes is_reconnect=True on retries; these adapters rejected that keyword and remained offline after an outage.

Changes

Validation

Check Result
Targeted gateway tests 203 passed
Adapter contract cases 23 passed
Real AST sweep 0 offenders
QQ reconnect invocation QQAdapter.connect(is_reconnect=True) accepted

Closes #52914.

Infographic

Gateway reconnect contract

luxuguang-leo and others added 5 commits July 9, 2026 18:45
…econnect compat

The base adapter's  signature was updated to include
, which the reconnect watcher passes as
 during reconnection. All other platform adapters were
updated, but QQAdapter was missed, causing:

    TypeError: QQAdapter.connect() got an unexpected keyword argument 'is_reconnect'

This leads to an infinite retry loop since every reconnect attempt fails
immediately with the same TypeError.

Fix: add  to QQAdapter.connect()'s signature.
QQBot has no server-side update queue, so the flag is accepted only for
interface conformance.

Test: new test_connect_accepts_is_reconnect_param verifies both
adapter.connect() and adapter.connect(is_reconnect=True) succeed without
raising.
…onnect

The gateway reconnect watcher forwards is_reconnect=True to every
adapter.connect() call on every retry. Adapters whose signature omits
the kwarg raise TypeError at every reconnect attempt and stay silently
disconnected — the exact bug that shipped for QQAdapter and only
surfaced after messages stopped flowing on the QQ channel for hours.

This test statically parses every adapter.py under gateway/platforms/
and plugins/platforms/ (via AST, so third-party SDKs like slack_sdk,
matrix-nio, aiohttp, telegram, etc. are NOT required in the test env)
and asserts every *Adapter class with an async connect() accepts
is_reconnect — either as a keyword-only argument or absorbed by
**kwargs.

Also fixes plugins/platforms/wecom/callback_adapter.py:WecomCallbackAdapter,
which the new test caught as a second offender. Same class of bug: bare
'async def connect(self)' signature would die on the first reconnect.

Companion to #59429 (which fixed the original QQAdapter offender).
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/qqbot QQ Bot adapter platform/wecom WeCom / WeChat Work adapter sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages labels Jul 10, 2026
@teknium1
teknium1 merged commit 540f901 into main Jul 10, 2026
31 checks passed
@teknium1
teknium1 deleted the hermes/hermes-c98ddd2f branch July 10, 2026 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/qqbot QQ Bot adapter platform/wecom WeCom / WeChat Work adapter sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: fix(qqbot): QQBot adapter.connect() missing is_reconnect parameter causes infinite retry loop

4 participants