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 {
62
62
}
63
63
64
64
async close ( ) : Promise < void > {
65
- // Remove our event listeners
65
+ // Remove our event listeners first
66
66
this . _stdin . off ( "data" , this . _ondata ) ;
67
67
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
+ }
72
76
73
77
// Clear the buffer and notify closure
74
78
this . _readBuffer . clear ( ) ;
You can’t perform that action at this time.
0 commit comments