-
Notifications
You must be signed in to change notification settings - Fork 47
fix(lsp): terminate LSP child process trees on failure #607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ import { Config } from "../config/config" | |
| import { spawn } from "child_process" | ||
| import { Instance } from "../project/instance" | ||
| import { Flag } from "@/flag/flag" | ||
| import { Shell } from "@/shell/shell" | ||
|
|
||
| export namespace LSP { | ||
| const log = Log.create({ service: "lsp" }) | ||
|
|
@@ -201,19 +202,19 @@ export namespace LSP { | |
| root, | ||
| }).catch((err) => { | ||
| s.broken.add(key) | ||
| handle.process.kill() | ||
| void Shell.killTree(handle.process, { exited: () => handle.process.exitCode !== null }) | ||
| log.error(`Failed to initialize LSP client ${server.id}`, { error: err }) | ||
| return undefined | ||
| }) | ||
|
|
||
| if (!client) { | ||
| handle.process.kill() | ||
| void Shell.killTree(handle.process, { exited: () => handle.process.exitCode !== null }) | ||
|
Comment on lines
203
to
+211
|
||
| return undefined | ||
|
Comment on lines
210
to
212
|
||
| } | ||
|
|
||
| const existing = s.clients.find((x) => x.root === root && x.serverID === server.id) | ||
| if (existing) { | ||
| handle.process.kill() | ||
| void Shell.killTree(handle.process, { exited: () => handle.process.exitCode !== null }) | ||
| return existing | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
exitedpredicate only checksexitCode !== null, but child processes can also exit via signal (wheresignalCodeis set andexitCodemay remain null). That can causeShell.killTreeto unnecessarily attempt SIGKILL/taskkill after the process already exited. Consider treating the process as exited when eitherexitCodeorsignalCodeis non-null (or attach anexitlistener and use a boolean, like otherkillTreecall sites).