MCP shutdown 'Event loop is closed' RuntimeError during task cancellation
Cluster 60197 · mcp. Data as of
2 open items. Fix merged in #74139 on 29 Jul 2026. Check it covers your case.
The short answer
- Known?
- Yes. 15 related items grouped here, 3 issues already closed.
- Fix event
- A fix was merged to main in PR #74139. Check it covers your case. No release data is tracked.
- Tracker
- The maintainers' tracker marks this
partially resolved, deciding PR #74139. That is separate from the fix event. - Still open
- 0 issues and 2 PRs.
Nearly all members concern a RuntimeError ('Event loop is closed') raised when MCP server tasks are cancelled or cleaned up during /exit, Ctrl+C, or shutdown. They include bug reports and several proposed changes, such as catching the error, moving cancel() into a try block, and draining or reaping parked tasks.
Open issues0
Open PRs2
Fixes on record
-
#74139 fix(mcp): drain the MCP loop and retain parked startup tasks for clean shutdown
files:
contributors/emails/[redacted:email],contributors/emails/[redacted:email],scripts/release.py,tests/tools/test_mcp_initial_connect_shutdown.py,tests/tools/test_mcp_stability.py,tests/tools/test_mcp_tool.py,tools/mcp_tool.py
9 PRs closed without merging
From the close comments: duplicate 4 · done elsewhere 2 · superseded by another PR 2 · merged via another change 1
-
#60205 fix(mcp): catch RuntimeError when canceling tasks on closed event loop during /exit · duplicate →
#60032,#60197 -
#60213 fix(mcp): move t.cancel() inside try block to prevent RuntimeError on exit (#60197) · duplicate →
#60032,#60205,#60104,#60197 -
#60287 fix(mcp): move t.cancel() inside try block to prevent RuntimeError on /exit · duplicate →
#60032,#60213,#60197 -
#61466 Fix MCP task cancellation after event loop shutdown · superseded by another PR →
#74139,#60197 -
#69420 fix(mcp): swallow RuntimeError when cancelling parked tasks on closed loop · merged via another change →
1f70ba6,#74139,#60032
Show 4 more
-
#71846 fix(mcp): catch RuntimeError in _wait_for_reconnect_or_shutdown cleanup · done elsewhere →
1f70ba6,#74139 -
#72054 fix(mcp): reap orphaned parked server task in _connect_server · done elsewhere →
#74139,#62026 -
#73190 fix(mcp): catch RuntimeError when cancelling tasks during /exit (#60197) · duplicate →
#60032 -
#73765 fix(mcp): suppress 'Event loop is closed' during shutdown race · superseded by another PR →
#74139,#60197
Closed issues · 3
How this cluster was grouped
-
Link evidence (
partly structural links): some members are connected by structural evidence (shared changed files, or a closing/superseded reference); the rest are joined by an automated relevance judgement over their text. - Members outside that structural core may belong to a different underlying problem.
-
Pairwise link density
0.16: the share of item pairs that carry a link, counting a structural link in full and a relevance-only link at 0.36.1.00means every pair is linked.
Pick up a Lab task
Check whether a fix covers the open issues here, with your own agent. Bring back evidence for maintainers.
Open the LabAt a glance
- Subsystem
- mcp
- Merged PRs
- #74139
- Closed issues
- 3
- Attempts
- 9 PRs closed without merging
- Fix link checked
- 29 Jul 2026