Skip to content

Commit 9e147ef

Browse files
committed
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 #23982
1 parent ce89bcb commit 9e147ef

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

packages/opencode/src/lsp/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ export async function create(input: { serverID: string; server: LSPServer.Handle
276276
},
277277
},
278278
}),
279-
INITIALIZE_TIMEOUT_MS,
279+
input.server.initializeTimeout ?? INITIALIZE_TIMEOUT_MS,
280280
).catch((err) => {
281281
logger.error("initialize error", { error: err })
282282
throw new InitializeError(

packages/opencode/src/lsp/server.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ const output = (cmd: string[], opts: Process.RunOptions = {}) => Process.text(cm
2727
export interface Handle {
2828
process: ChildProcessWithoutNullStreams
2929
initialization?: Record<string, any>
30+
/** Override the default 45 s initialize-request timeout (ms). */
31+
initializeTimeout?: number
3032
}
3133

3234
type RootFunction = (file: string, ctx: InstanceContext) => Promise<string | undefined>
@@ -1290,6 +1292,7 @@ export const JDTLS: Info = {
12901292
cwd: root,
12911293
},
12921294
),
1295+
initializeTimeout: 180_000,
12931296
}
12941297
},
12951298
}
@@ -1389,6 +1392,7 @@ export const KotlinLS: Info = {
13891392
process: spawn(launcherScript, ["--stdio"], {
13901393
cwd: root,
13911394
}),
1395+
initializeTimeout: 180_000,
13921396
}
13931397
},
13941398
}

0 commit comments

Comments
 (0)