Skip to content

fix(integrations): cancel the Hermes MCP actor once so a repeat shutdown cannot orphan bm mcp - #2052

Merged
phernandez merged 2 commits into
mainfrom
fix/1649-hermes-cancel-once
Nov 4, 2026
Merged

phernandez merged 2 commits into
mainfrom
fix/1649-hermes-cancel-once

Conversation

@phernandez

Copy link
Copy Markdown
Member

Salvages #2049 by @tonydzi onto an in-repo branch so CI runs, and fixes its open Codex finding. Fixes #1649.

Commit 1 (@tonydzi, unchanged). _BmMcpActor.shutdown() cancels the actor task at most once per run. A second shutdown() during the timed-out start's teardown used to cancel again. That second cancel broke stdio_client's shielded teardown and left bm mcp running. See #2049 for the reproduction against the real mcp transport.

Commit 2 (follow-up). On a ready actor, the first shutdown() stops it gracefully by resolving the stop future. That path didn't record the stop, so a second shutdown() during the same teardown still called task.cancel(). One _stop_sent flag now covers both the cancel and the graceful stop.

The new test test_repeat_shutdown_does_not_cancel_graceful_teardown fails on commit 1 and passes on commit 2.

Verification: just package-check-hermes (361 passed, 21 skipped) and just fast-check.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CMYVL4TcbWdXhdvAzxfqjo

tonydzi and others added 2 commits November 4, 2026 15:45
…own cannot orphan bm mcp

When start() times out it cancels the actor task, and stdio_client then
runs a shielded teardown that closes stdin, waits, and kills the child's
process group. If shutdown() is called again before that teardown ends
(the provider's own cleanup after the failed start, or the host's
shutdown hook), request_stop() cancels the task a second time. A repeat
native cancel breaks the shield, the teardown is abandoned, and the
`bm mcp` child keeps running.

Cancel the task at most once per run; later shutdown() calls only join.

Fixes #1649

Signed-off-by: tonydzi <194927794+tonydzi@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…op request

#2049's guard covered repeat cancels, but a ready actor's first
shutdown() resolves the stop future without marking the stop, so a
second shutdown() during stdio teardown still cancelled the task and
could orphan bm mcp (Codex review on #2049). One _stop_sent flag now
covers both paths, and a regression test drives the graceful one.

Co-Authored-By: tonydzi <194927794+tonydzi@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CMYVL4TcbWdXhdvAzxfqjo
Signed-off-by: phernandez <paul@basicmachines.co>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-04T21:47:25.396081Z ca0e4ac PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@phernandez
phernandez merged commit d612d35 into main Nov 4, 2026
25 checks passed
@phernandez
phernandez deleted the fix/1649-hermes-cancel-once branch November 4, 2026 21:51
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.

_BmMcpActor orphans its bm mcp child when start() times out: no subprocess kill path

2 participants