Skip to content

fix(mcp): kill entire process group when closing StdioClientTransport#170

Open
hernandez42 wants to merge 1 commit into
OpenBMB:mainfrom
hernandez42:main
Open

fix(mcp): kill entire process group when closing StdioClientTransport#170
hernandez42 wants to merge 1 commit into
OpenBMB:mainfrom
hernandez42:main

Conversation

@hernandez42

Copy link
Copy Markdown

Summary

Root cause: When is called, it sends to the wrapper process. However, does NOT forward to its child process running . The process in turn spawns a browser grandchild. Result: a session ends → tsx dies → + keep running → process leak.

Fix: Capture the PID at transport creation time, and use in to atomically wipe the entire process tree (tsx → node → Chromium).

Changes

  • : Added field and process-group kill in

Impact

Before After
30+ orphaned playwright processes Sessions clean up fully on close

Test: 0 should stay at 0 during idle.

Root cause: tsx wrapper does NOT forward SIGTERM to its child node process.
When McpClient.close() was called, only the tsx process received SIGTERM,
leaving the playwright-mcp node and Chromium grandchild processes orphaned.

Fix: capture the tsx PID and use kill(-pid, SIGKILL) in close() to
atomically wipe the entire process tree (tsx → node → Chromium).

This permanently fixes the playwright browser leak issue where sessions
accumulated 30+ orphaned Chromium processes over time.
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