@@ -91,7 +91,6 @@ export function getDefaultEnvironment(): Record<string, string> {
9191 */
9292export class StdioClientTransport implements Transport {
9393 private _process ?: ChildProcess ;
94- private _abortController : AbortController = new AbortController ( ) ;
9594 private _readBuffer : ReadBuffer = new ReadBuffer ( ) ;
9695 private _serverParams : StdioServerParameters ;
9796 private _stderrStream : PassThrough | null = null ;
@@ -126,17 +125,11 @@ export class StdioClientTransport implements Transport {
126125 } ,
127126 stdio : [ 'pipe' , 'pipe' , this . _serverParams . stderr ?? 'inherit' ] ,
128127 shell : false ,
129- signal : this . _abortController . signal ,
130128 windowsHide : process . platform === 'win32' && isElectron ( ) ,
131129 cwd : this . _serverParams . cwd
132130 } ) ;
133131
134132 this . _process . on ( 'error' , error => {
135- if ( error . name === 'AbortError' ) {
136- // Expected when close() is called.
137- return ;
138- }
139-
140133 reject ( error ) ;
141134 this . onerror ?.( error ) ;
142135 } ) ;
@@ -225,10 +218,18 @@ export class StdioClientTransport implements Transport {
225218 // ignore
226219 }
227220
228- this . _abortController . abort ( ) ;
229-
230221 await Promise . race ( [ closePromise , new Promise ( resolve => setTimeout ( resolve , 2_000 ) . unref ( ) ) ] ) ;
231222
223+ if ( processToClose . exitCode === null ) {
224+ try {
225+ processToClose . kill ( 'SIGTERM' ) ;
226+ } catch {
227+ // ignore
228+ }
229+
230+ await Promise . race ( [ closePromise , new Promise ( resolve => setTimeout ( resolve , 2_000 ) . unref ( ) ) ] ) ;
231+ }
232+
232233 if ( processToClose . exitCode === null ) {
233234 try {
234235 processToClose . kill ( 'SIGKILL' ) ;
0 commit comments