-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
The StdioClientTransport.close()
method doesn't properly terminate spawned child processes, causing
memory leaks in applications that frequently connect/disconnect from STDIO MCP servers.
In client/stdio.js
, the close()
method only aborts the spawn signal and nullifies the process
reference, but doesn't actually kill the running child process:
async close() {
this._abortController.abort(); // Only prevents new spawns
this._process = undefined; // Just removes reference
this._readBuffer.clear();
}
To Reproduce
FOR 1000 times:
transport = new StdioClientTransport(server_command)
client = new Client()
client.connect(transport) // spawns child process
pid = transport.pid
client.close() // BUG: doesn't kill child process
// Process with 'pid' is still running (memory leak)
// Result: 1000 orphaned processes still running
Expected behavior
When close() is called, the spawned child process should be terminated to prevent resource leaks.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working