Don't remove drain listeners

This commit is contained in:
Jerome 2025-01-03 18:45:11 +00:00
commit 6ebf67ea73
No known key found for this signature in database
2 changed files with 5 additions and 6 deletions

View file

@ -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

View file

@ -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?.();