You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(lsp): typescript bunx fallback never detects a missing bunx — the try/catch around spawn is dead #135
When no runnable typescript-language-server is found (neither the project-local one nor one on PATH), TypescriptServer.spawn falls back to bunx inside a try/catch (packages/lsp/src/server/typescript.ts:319-330):
try{constproc=spawn('bunx',[`typescript-language-server@${TS_LANGUAGE_SERVER_VERSION}`,'--stdio'],{ … })attachLSPProcessHandlers(proc,'typescript')return{process: proc}}catch(err){log.error({ err },'Failed to spawn typescript-language-server via bunx')returnundefined}
spawn from node:child_process does not throw when the command is missing. It returns a child process and later emits an async error event (ENOENT). This was confirmed under both Bun and Node while working on #134. So when bunx is not on PATH, the catch never runs:
spawn returns a handle to a process that never started, rather than undefined.
LSPManager.schedule (packages/lsp/src/index.ts) marks a server broken only when spawn returns undefined or throws. It treats this dead handle as live and waits out the initialize timeout before giving up.
The only log line is the generic LSP process error from attachLSPProcessHandlers. The Failed to spawn … via bunx message never appears.
Expected
Check for bunx before spawning, as BiomeServer does since #134 (packages/lsp/src/server/biome.ts:77-89):
Add a case to the existing TypescriptServer classic-fallback tests in packages/lsp/test/unit/server.test.ts, modeled on the "returns undefined with the install hint when bunx is missing" test from #134. Set PATH to an empty temp dir, then assert that spawn returns undefined and that log.warn was called with the hint. The test should fail when the pre-check is removed.
Notes
PyrightServer (packages/lsp/src/server/pyright.ts:21-32) has the same dead try/catch around spawn('bunx', ['pyright-langserver', '--stdio']). It could get the same fix in this change or in a separate issue. Its bunx call is also unpinned, and it calls Bun.which('pyright-langserver') without the explicit PATH.
Activity