Skip to content

Commit 9eb7dc4

Browse files
committed
fix: dangling process on exit
1 parent ee128b2 commit 9eb7dc4

3 files changed

Lines changed: 17 additions & 7 deletions

File tree

src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,9 @@ async fn serve() -> anyhow::Result<()> {
527527
// log::warn!("Missing LSP response handler for {:?}", id);
528528
}
529529
Message::Notification(note) => {
530+
if note.method == "exit" {
531+
break;
532+
}
530533
if let Err(err) = handle_notification(ctx, note).await {
531534
log::error!("{}", err);
532535
}
@@ -536,7 +539,13 @@ async fn serve() -> anyhow::Result<()> {
536539
});
537540
tokio::task::spawn_blocking(move || {
538541
while let Ok(msg) = lsp_receiver.recv() {
542+
let need_exit = if let Message::Notification(note) = &msg {
543+
note.method == "exit"
544+
} else {
545+
false
546+
};
539547
sender.send(msg).unwrap();
548+
if need_exit { break; }
540549
}
541550
})
542551
};

src/main.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ fn main() -> anyhow::Result<()> {
1010
.enable_all()
1111
.build()
1212
.unwrap();
13-
runtime.block_on(async { glass_easel_analyzer::run().await })?;
14-
Ok(())
13+
if let Err(err) = runtime.block_on(async { glass_easel_analyzer::run().await }) {
14+
eprintln!("{}", err);
15+
std::process::exit(1);
16+
} else {
17+
std::process::exit(0);
18+
}
1519
}

vscode-extension/src/client.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,7 @@ export class Client {
8383
const run: Executable = {
8484
command,
8585
args,
86-
options: {
87-
env: {
88-
RUST_BACKTRACE: '1',
89-
},
90-
},
86+
options: {},
9187
}
9288
const debug: Executable = {
9389
command,
@@ -155,5 +151,6 @@ export class Client {
155151
this.tsServerHost?.destroy()
156152
this.tsServerHost = null
157153
await this.client?.stop()
154+
await this.client?.dispose()
158155
}
159156
}

0 commit comments

Comments
 (0)