From 9e147ef185e25d5f4af7ab07ee266a7ff235fe7e Mon Sep 17 00:00:00 2001 From: norbu <93921032+norbu35@users.noreply.github.com> Date: Mon, 4 May 2026 07:02:28 +0800 Subject: [PATCH] fix: increase LSP initialize timeout for JDTLS and KotlinLS JDTLS (Eclipse JDT Language Server) and KotlinLS are JVM-based language servers that must perform Gradle project sync and workspace indexing during LSP initialize. For real-world projects this routinely takes 60-180 seconds, well above the default 45 s timeout. Add an optional initializeTimeout field to the LSP server Handle interface so built-in servers can declare their timeout needs. Use it in the client with the existing 45 s constant as the default. Set 180 s for JDTLS and KotlinLS, both of which run on the JVM and trigger Gradle sync during initialization. Closes anomalyco/opencode#23982 --- packages/opencode/src/lsp/client.ts | 2 +- packages/opencode/src/lsp/server.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/opencode/src/lsp/client.ts b/packages/opencode/src/lsp/client.ts index 809ea95091b6..528f7aa2e00e 100644 --- a/packages/opencode/src/lsp/client.ts +++ b/packages/opencode/src/lsp/client.ts @@ -276,7 +276,7 @@ export async function create(input: { serverID: string; server: LSPServer.Handle }, }, }), - INITIALIZE_TIMEOUT_MS, + input.server.initializeTimeout ?? INITIALIZE_TIMEOUT_MS, ).catch((err) => { logger.error("initialize error", { error: err }) throw new InitializeError( diff --git a/packages/opencode/src/lsp/server.ts b/packages/opencode/src/lsp/server.ts index b8861d1f8167..b87c5adc4a52 100644 --- a/packages/opencode/src/lsp/server.ts +++ b/packages/opencode/src/lsp/server.ts @@ -27,6 +27,8 @@ const output = (cmd: string[], opts: Process.RunOptions = {}) => Process.text(cm export interface Handle { process: ChildProcessWithoutNullStreams initialization?: Record + /** Override the default 45 s initialize-request timeout (ms). */ + initializeTimeout?: number } type RootFunction = (file: string, ctx: InstanceContext) => Promise @@ -1290,6 +1292,7 @@ export const JDTLS: Info = { cwd: root, }, ), + initializeTimeout: 180_000, } }, } @@ -1389,6 +1392,7 @@ export const KotlinLS: Info = { process: spawn(launcherScript, ["--stdio"], { cwd: root, }), + initializeTimeout: 180_000, } }, }