From d15794004e25cfc07db7e2b346ef91b96d936bb9 Mon Sep 17 00:00:00 2001 From: sisyphus-dev-ai Date: Sat, 24 Jan 2026 07:14:12 +0000 Subject: [PATCH] fix(lsp): add Bun version check for Windows LSP segfault bug On Windows with Bun v1.3.5 and earlier, spawning LSP servers causes a segmentation fault crash. This is a known Bun bug fixed in v1.3.6. Added version check before LSP server spawn that: - Detects Windows + affected Bun versions (< 1.3.6) - Throws helpful error with upgrade instructions instead of crashing - References the Bun issue for users to track Closes #1047 --- src/tools/lsp/client.ts | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/tools/lsp/client.ts b/src/tools/lsp/client.ts index 493f4e351..569efb54d 100644 --- a/src/tools/lsp/client.ts +++ b/src/tools/lsp/client.ts @@ -5,6 +5,37 @@ import { pathToFileURL } from "node:url" import { getLanguageId } from "./config" import type { Diagnostic, ResolvedServer } from "./types" +/** + * Check if the current Bun version is affected by Windows LSP crash bug. + * Bun v1.3.5 and earlier have a known segmentation fault issue on Windows + * when spawning LSP servers. This was fixed in Bun v1.3.6. + * See: https://github.com/oven-sh/bun/issues/25798 + */ +function checkWindowsBunVersion(): { isAffected: boolean; message: string } | null { + if (process.platform !== "win32") return null + + const version = Bun.version + const [major, minor, patch] = version.split(".").map((v) => parseInt(v.split("-")[0], 10)) + + // Bun v1.3.5 and earlier are affected + if (major < 1 || (major === 1 && minor < 3) || (major === 1 && minor === 3 && patch < 6)) { + return { + isAffected: true, + message: + `⚠️ Windows + Bun v${version} detected: Known segmentation fault bug with LSP.\n` + + ` This causes crashes when using LSP tools (lsp_diagnostics, lsp_goto_definition, etc.).\n` + + ` \n` + + ` SOLUTION: Upgrade to Bun v1.3.6 or later:\n` + + ` powershell -c "irm bun.sh/install.ps1|iex"\n` + + ` \n` + + ` WORKAROUND: Use WSL instead of native Windows.\n` + + ` See: https://github.com/oven-sh/bun/issues/25798`, + } + } + + return null +} + interface ManagedClient { client: LSPClient lastUsedAt: number @@ -223,6 +254,13 @@ export class LSPClient { ) {} async start(): Promise { + const windowsCheck = checkWindowsBunVersion() + if (windowsCheck?.isAffected) { + throw new Error( + `LSP server cannot be started safely.\n\n${windowsCheck.message}` + ) + } + this.proc = spawn(this.server.command, { stdin: "pipe", stdout: "pipe",