fix(mcp): drain connecting tasks before loop shutdown - #67956
Closed
nuch1011 wants to merge 2 commits into
Closed
Conversation
Collaborator
Recommend consolidating on #67956 because it is the older of the two identical PRs (opened ~21 min earlier); #67961 can be closed as a duplicate. Neither has CI checks configured, both are mergeable. Reviewers: note that the one-shot drain in |
Author
|
Closed at the repository owner's direction. Superseded patch remains private; no change should be proposed against the official NousResearch branch. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Root cause
shutdown_mcp_servers()only knew about fully registered servers. A fast one-shot command could exit while background discovery still had anMCPServerTask.run()coroutine connecting. The loop was closed first, so later coroutine finalization tried to cancel work on a closed event loop and printedRuntimeError: Event loop is closeddespite exit code 0.Verification
scripts/run_tests.sh tests/tools/test_mcp_tool.py tests/tools/test_mcp_stdio_watchdog.py— 219 passedscripts/run_tests.sh tests/hermes_cli/test_tui_resume_flow.py— 71 passed.venv/bin/ruff check tools/mcp_tool.py tests/tools/test_mcp_tool.py— passedhermes chat -qreturned the expected response and exited 0 with no traceback, pending-task warning, or event-loop-closed errororigin/mainreproducedException ignored in: <coroutine object MCPServerTask.run ...>/RuntimeError: Event loop is closedNo credentials or secret values are included in this PR.