Skip to content

fix(probe): stop descendant work after POSIX timeouts - #751

Open
rudycelekli wants to merge 1 commit into
Panniantong:mainfrom
rudycelekli:fix/probe-descendant-timeout
Open

rudycelekli wants to merge 1 commit into
Panniantong:mainfrom
rudycelekli:fix/probe-descendant-timeout

Conversation

@rudycelekli

Copy link
Copy Markdown

Problem

A timed-out POSIX health probe kills its immediate command but leaves children of CLI wrappers running. Repeated doctor calls or retries can therefore accumulate work after the caller has received a timeout.

The native regression launches a wrapper that starts a child; the child writes a marker after the one-second probe deadline. On unchanged main the marker appears, both when the wrapper is still running and when it has already exited while the child holds its output pipes.

Change

Give each POSIX health probe its own process session. On timeout or interruption, terminate that owned process group before the normal subprocess cleanup. Preserve status/output classification, environment isolation, retries, and the existing non-POSIX subprocess.run path. Existing channel unit tests now stub the POSIX execution boundary as well as the non-POSIX boundary; native probe tests still execute real processes.

This addresses orphaned probe work, not an overall doctor deadline or parallel channel collection. It does not claim to resolve the entire hang report in #732. The separate inherited-pipe hang hypothesis was tested and did not reproduce on this POSIX Python runtime.

Validation

  • Before: both real descendant-work regressions fail; cleanup fences stop only owned fixture processes.
  • After: both pass; existing native probe success/error/env/retry tests pass. Four simulated non-POSIX cases verify unchanged subprocess arguments and classifications.
  • Full repository suite: 613 passed. Ruff check and diff whitespace checks pass; new test and probe module formatting pass.
  • MyPy retains the same three unrelated baseline MCP SDK 2.2 diagnostics, with no new errors. Unchanged main's formatting check already fails in 54 files.
  • Native execution tested on macOS/Python 3.11. Native Windows behavior is not locally verified; its existing execution path is preserved and covered by simulated contract tests.

AI assistance: prepared with Codex and independently reviewed before submission.

Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com>
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.

1 participant