From aa4dba1541c4f220417bd715e1b944b005d80d46 Mon Sep 17 00:00:00 2001 From: Aiden Cline <63023139+rekram1-node@users.noreply.github.com> Date: Thu, 21 Aug 2025 12:06:32 -0500 Subject: [PATCH] fix: if lsp fails to spawn it shouldn't inject errors into edit diagnostics (#2145) --- packages/opencode/src/lsp/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/opencode/src/lsp/index.ts b/packages/opencode/src/lsp/index.ts index 56d2545e7..3703284e7 100644 --- a/packages/opencode/src/lsp/index.ts +++ b/packages/opencode/src/lsp/index.ts @@ -126,7 +126,11 @@ export namespace LSP { result.push(match) continue } - const handle = await server.spawn(App.info(), root) + const handle = await server.spawn(App.info(), root).catch((err) => { + s.broken.add(root + server.id) + log.error(`Failed to spawn LSP server ${server.id}`, { error: err }) + return undefined + }) if (!handle) continue const client = await LSPClient.create({ serverID: server.id, @@ -135,7 +139,7 @@ export namespace LSP { }).catch((err) => { s.broken.add(root + server.id) handle.process.kill() - log.error("", { error: err }) + log.error(`Failed to initialize LSP client ${server.id}`, { error: err }) }) if (!client) continue s.clients.push(client)