Added clean shutdown + tests
This commit is contained in:
parent
3f178b2b7e
commit
7c91349363
1 changed files with 74 additions and 0 deletions
|
|
@ -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?.();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue