Added clean shutdown + tests

This commit is contained in:
Jerome 2025-01-03 16:29:06 +00:00
commit 7c91349363
No known key found for this signature in database

View file

@ -62,8 +62,16 @@ export class StdioServerTransport implements Transport {
}
async close(): Promise<void> {
// Remove all event listeners
this._stdin.off("data", this._ondata);
this._stdin.off("error", this._onerror);
this._stdout.removeAllListeners('drain');
// Destroy both streams
this._stdin.destroy();
this._stdout.destroy();
// Clear the buffer and notify closure
this._readBuffer.clear();
this.onclose?.();
}