From 85e3632ee7bd53a74b4877fe0940e2576902fd06 Mon Sep 17 00:00:00 2001 From: shellRaining Date: Fri, 18 Jul 2025 15:51:22 +0800 Subject: [PATCH] fix: clean up event listeners in StdioClientTransport.close() --- src/client/stdio.ts | 8 ++++++++ 1 file changed, 8 insertions(+) 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(); }