fix(cli): harden no-daemon teardown
This commit is contained in:
@@ -252,15 +252,22 @@ export class LspClient {
|
||||
}
|
||||
|
||||
// Dispose - Best-effort shutdown; kills the process if it doesn't exit.
|
||||
async dispose(): Promise<void> {
|
||||
async dispose(options: { graceful?: boolean } = {}): Promise<void> {
|
||||
const graceful = options.graceful ?? true;
|
||||
if (this.conn) {
|
||||
try {
|
||||
await this.conn.sendRequest("shutdown", undefined);
|
||||
this.conn.sendNotification("exit");
|
||||
} catch {
|
||||
// Ignore - we're tearing down anyway.
|
||||
if (graceful) {
|
||||
try {
|
||||
await this.conn.sendRequest("shutdown", undefined);
|
||||
this.conn.sendNotification("exit");
|
||||
} catch {
|
||||
// Ignore - we're tearing down anyway.
|
||||
}
|
||||
}
|
||||
try {
|
||||
this.conn.dispose();
|
||||
} catch {
|
||||
// Ignore - connection may already be closed.
|
||||
}
|
||||
this.conn.dispose();
|
||||
}
|
||||
if (this.proc && !this.proc.killed) {
|
||||
this.proc.kill();
|
||||
|
||||
Reference in New Issue
Block a user