From 0afd8a40fe297ff6ceff323602d400fcb52f3419 Mon Sep 17 00:00:00 2001 From: eleung <=> Date: Tue, 22 Apr 2025 12:43:47 +0800 Subject: [PATCH] fix(stdio): ensure child process is killed on close to prevent orphaned subprocesses --- src/client/stdio.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/client/stdio.ts b/src/client/stdio.ts index b83bf27c..8352843e 100644 --- a/src/client/stdio.ts +++ b/src/client/stdio.ts @@ -187,7 +187,14 @@ export class StdioClientTransport implements Transport { async close(): Promise { this._abortController.abort(); - this._process = undefined; + if (this._process) { + try { + this._process.kill(); + } catch (e) { + // Optionally log or ignore + } + this._process = undefined; + } this._readBuffer.clear(); }