diff --git a/src/client/stdio.ts b/src/client/stdio.ts index 62292ce10..eb10de06e 100644 --- a/src/client/stdio.ts +++ b/src/client/stdio.ts @@ -215,6 +215,14 @@ export class StdioClientTransport implements Transport { async close(): Promise { this._abortController.abort(); + + if (this._process) { + this._process.removeAllListeners(); + this._process.stdin?.removeAllListeners(); + this._process.stdout?.removeAllListeners(); + this._process.stderr?.removeAllListeners(); + } + this._process = undefined; this._readBuffer.clear(); }