{"record":{"id":"25cc88692ad47703","repo":"can1357/oh-my-pi","slug":"failed-to-initialize-lsp-no-response","errorCode":null,"errorMessage":"Failed to initialize LSP: no response","messagePattern":"Failed to initialize LSP: no response","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/lsp/client.ts","lineNumber":1102,"sourceCode":"\t\ttry {\n\t\t\t// Send initialize request\n\t\t\tconst initResult = (await sendRequest(\n\t\t\t\tclient,\n\t\t\t\t\"initialize\",\n\t\t\t\t{\n\t\t\t\t\tprocessId: process.pid,\n\t\t\t\t\trootUri: fileToUri(cwd),\n\t\t\t\t\trootPath: cwd,\n\t\t\t\t\tcapabilities: CLIENT_CAPABILITIES,\n\t\t\t\t\tinitializationOptions: config.initOptions ?? {},\n\t\t\t\t\tworkspaceFolders: currentWorkspaceFolders(client),\n\t\t\t\t},\n\t\t\t\tsignal,\n\t\t\t\tinitTimeoutMs,\n\t\t\t)) as { capabilities?: unknown };\n\n\t\t\tif (!initResult) {\n\t\t\t\tthrow new Error(\"Failed to initialize LSP: no response\");\n\t\t\t}\n\n\t\t\tclient.serverCapabilities = initResult.capabilities as LspClient[\"serverCapabilities\"];\n\n\t\t\t// Finish the initialize handshake before publishing the client as ready.\n\t\t\tawait sendNotification(client, \"initialized\", {}, signal);\n\t\t\tawait sendNotification(\n\t\t\t\tclient,\n\t\t\t\t\"workspace/didChangeConfiguration\",\n\t\t\t\t{ settings: config.settings ?? {} },\n\t\t\t\tsignal,\n\t\t\t);\n\n\t\t\tclient.status = \"ready\";\n\t\t\t// Publish only after init succeeds: pre-init clients are reachable\n\t\t\t// solely through clientLocks, so concurrent callers (warmup vs first\n\t\t\t// tool call) wait for init instead of using an unacknowledged client.\n\t\t\tif (invalidatedClientKeys.has(key)) {","sourceCodeStart":1084,"sourceCodeEnd":1120,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/lsp/client.ts#L1084-L1120","documentation":"During client startup the library sends the LSP `initialize` request with a timeout. If the request resolves to nothing (null/undefined result) rather than a capabilities object, the client cannot proceed and throws this error — the server never answered the handshake.","triggerScenarios":"The initialize request completed its await without producing an initResult: server closed the connection, the framed response never arrived, or the transport returned an empty result before initTimeoutMs elapsed.","commonSituations":"Server binary is a CLI wrapper that exits immediately; wrong command args so the process isn't a language server; server speaks a different protocol version; server killed by OOM during startup.","solutions":["Verify the configured command actually starts a language server (run it manually)","Check server stderr/logs for crash output during initialization","Increase initTimeoutMs if the server is slow but functional","Update or reinstall the language server binary"],"exampleFix":"// before\ncommand: \"typescript-language-server\"\n// after\ncommand: \"typescript-language-server\", args: [\"--stdio\"]","handlingStrategy":"try-catch","validationCode":"// Pre-flight: confirm the command starts and stays alive\nconst proc = Bun.spawn([config.command, ...config.args], { stderr: 'pipe' });\nawait Bun.sleep(500);\nif (proc.exitCode !== null) throw new Error(`LSP server exited immediately: ${await new Response(proc.stderr).text()}`);\nproc.kill();","typeGuard":null,"tryCatchPattern":"try {\n  const client = await getConfigOrCreate(config, cwd);\n} catch (err) {\n  if (err.message === 'Failed to initialize LSP: no response') {\n    logger.error('LSP server did not answer initialize', { command: config.command });\n    // check server logs / reinstall server\n  }\n  throw err;\n}","preventionTips":["Manually run the configured command with --stdio to confirm it is a real language server","Match server args to the expected transport (e.g. --stdio)","Keep the language server updated; old protocol versions may fail the handshake","Raise initTimeoutMs for slow-starting servers"],"tags":["lsp","initialization","timeout","protocol"],"backgroundTag":"lsp-initialize-no-response","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}