Skip to content

fix(dingtalk): close session websocket on disconnect#10070

Closed
Asunfly wants to merge 1 commit into
NousResearch:mainfrom
Asunfly:fix/dingtalk-graceful-shutdown
Closed

fix(dingtalk): close session websocket on disconnect#10070
Asunfly wants to merge 1 commit into
NousResearch:mainfrom
Asunfly:fix/dingtalk-graceful-shutdown

Conversation

@Asunfly

@Asunfly Asunfly commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • close the active DingTalk session websocket before awaiting adapter shutdown
  • bound the wait on the stream task during disconnect so gateway stop/restart does not hang indefinitely
  • add a regression test covering websocket cleanup during disconnect()

Why

In local verification on WSL, hermes-gateway.service could get stuck in stop-sigterm and be SIGKILLed during restart while DingTalk was configured. Closing the SDK websocket explicitly gives the stream loop a clean shutdown path instead of waiting for the remote side to time out.

This PR is intentionally scoped to shutdown behavior only. Existing open DingTalk PRs already cover CallbackMessage parsing, async SDK compatibility, and oapi.dingtalk.com webhook routing.

Related: #7562

Test plan

  • pytest tests/gateway/test_dingtalk.py::TestConnect::test_disconnect_closes_session_websocket -v
  • pytest tests/gateway/test_dingtalk.py -q
  • manually verified local systemctl --user restart hermes-gateway no longer hangs in the idle DingTalk case after applying the patch

@teknium1

Copy link
Copy Markdown
Contributor

Merged via #11556 (#11556). Your commit was cherry-picked with authorship preserved in git log (7c932c5). Thanks for the tight, well-tested fix — the systemd stop-sigterm hang was affecting anyone running DingTalk under hermes-gateway.service, and the asyncio.wait_for(task, timeout=2.0) bound is exactly the right shape.

@Asunfly Asunfly deleted the fix/dingtalk-graceful-shutdown branch April 20, 2026 01:58
ulasbilgen pushed a commit to ulasbilgen/hermes-adhd-agent that referenced this pull request May 1, 2026
aj-nt pushed a commit to aj-nt/hermes-agent that referenced this pull request May 1, 2026
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
Egavasyug pushed a commit to Egavasyug/hermes-agent that referenced this pull request Jun 10, 2026
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