File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -62,13 +62,17 @@ export class StdioServerTransport implements Transport {
6262 }
6363
6464 async close ( ) : Promise < void > {
65- // Remove our event listeners
65+ // Remove our event listeners first
6666 this . _stdin . off ( "data" , this . _ondata ) ;
6767 this . _stdin . off ( "error" , this . _onerror ) ;
68-
69- // Destroy streams to ensure they're fully closed
70- this . _stdin . destroy ( ) ;
71- this . _stdout . destroy ( ) ;
68+
69+ // Check if we were the only data listener
70+ const remainingDataListeners = this . _stdin . listenerCount ( 'data' ) ;
71+ if ( remainingDataListeners === 0 ) {
72+ // Only pause stdin if we were the only listener
73+ // This prevents interfering with other parts of the application that might be using stdin
74+ this . _stdin . pause ( ) ;
75+ }
7276
7377 // Clear the buffer and notify closure
7478 this . _readBuffer . clear ( ) ;
You can’t perform that action at this time.
0 commit comments