Repository navigation
Commit baddcdc
committed
fix(stdio): remove listeners in close() to prevent EventEmitter memory leak
StdioClientTransport.close() was not removing the listeners attached in
start() on the stdio pipes. The 'data' listener on stdout keeps the stream
flowing, and the 'drain' listener added internally by stderr.pipe()
accumulates when back-pressure is triggered, eventually exceeding the
default MaxListeners limit of 10 and emitting:
MaxListenersExceededWarning: Possible EventEmitter memory leak detected.
11 drain listeners added to [WriteStream].
This commit adds proper cleanup in close():
- unpipe() the stderr stream to remove the internal 'drain' listener
- removeAllListeners() on stdin, stdout, and stderr
This is consistent with the existing _dispose() method which already
destroys the pipe handles, and addresses the root cause reported in
modelcontextprotocol#780 and modelcontextprotocol#3070.
Refs: modelcontextprotocol#780, modelcontextprotocol#30701 parent 9adb8d5 commit baddcdc
1 file changed
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
313 | 313 | | |
314 | 314 | | |
315 | 315 | | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
316 | 328 | | |
317 | 329 | | |
318 | 330 | | |
| |||
0 commit comments