Skip to content

fix(dingtalk): close SDK websocket on disconnect (systemd stop-sigterm hang)#11556

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-e52e6172
Apr 17, 2026
Merged

fix(dingtalk): close SDK websocket on disconnect (systemd stop-sigterm hang)#11556
teknium1 merged 2 commits into
mainfrom
hermes/hermes-e52e6172

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Salvages #10070 (Asunfly — authorship preserved). Fixes a real systemd-level hang: hermes-gateway.service can get stuck in stop-sigterm and be SIGKILLed on restart when DingTalk is configured, because the adapter's disconnect() cancels the stream task but never closes the SDK websocket — it just waits for the remote side to time out.

Changes (from Asunfly's commit)

  • Explicitly await stream_client.websocket.close() at the start of disconnect() so the SDK's internal recv loop exits promptly.
  • Bound the stream task await with asyncio.wait_for(..., timeout=2.0) instead of an unbounded await, and catch TimeoutError so disconnect never hangs.
  • Regression test: test_disconnect_closes_session_websocket — mocks a websocket on _stream_client, kicks a blocked stream task, calls disconnect(), asserts websocket.close was awaited exactly once and the task reference was cleared.

Tests

Authorship

Commit 7099c557 preserves Asunfly <Asunfly@users.noreply.github.com> as author. Merge with --rebase to keep attribution. Also adds Asunfly to scripts/release.py AUTHOR_MAP so the release CI doesn't block on unmapped email.

Closes

Closes #10070 on merge with credit.

@teknium1 teknium1 merged commit 0231f88 into main Apr 17, 2026
5 checks passed
@teknium1 teknium1 deleted the hermes/hermes-e52e6172 branch April 17, 2026 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants