Don't remove drain listeners
This commit is contained in:
parent
7c91349363
commit
6ebf67ea73
2 changed files with 5 additions and 6 deletions
|
|
@ -123,7 +123,7 @@ test("should properly clean up resources when closed", async () => {
|
|||
const transport = new StdioServerTransport(mockStdin, mockStdout);
|
||||
await transport.start();
|
||||
|
||||
// Send a message to potentially create 'drain' listeners
|
||||
// Send a message to potentially create listeners
|
||||
await transport.send({ jsonrpc: "2.0", method: "test", id: 1 });
|
||||
|
||||
// Close the transport
|
||||
|
|
|
|||
|
|
@ -62,15 +62,14 @@ export class StdioServerTransport implements Transport {
|
|||
}
|
||||
|
||||
async close(): Promise<void> {
|
||||
// Remove all event listeners
|
||||
// Remove our event listeners
|
||||
this._stdin.off("data", this._ondata);
|
||||
this._stdin.off("error", this._onerror);
|
||||
this._stdout.removeAllListeners('drain');
|
||||
|
||||
// Destroy both streams
|
||||
|
||||
// Destroy streams to ensure they're fully closed
|
||||
this._stdin.destroy();
|
||||
this._stdout.destroy();
|
||||
|
||||
|
||||
// Clear the buffer and notify closure
|
||||
this._readBuffer.clear();
|
||||
this.onclose?.();
|
||||
|
|
|
|||
Loading…
Reference in a new issue