-
Notifications
You must be signed in to change notification settings - Fork 52
fix(lsp): terminate LSP child process trees on failure #607
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).