feat: allow per-server request/init timeout overrides

Merged
MI
2mo ago
+260-8

Summary

  • Some LSP servers (e.g. kotlin-language-server on a multi-module Gradle project) take far longer to answer initialize or individual requests than the global defaults (60s / 15s) allow, causing spurious timeouts even though the server would eventually respond.
  • Adds optional requestTimeoutMs / initTimeoutMs fields to a server entry in .pi/lsp-client.json / ~/.pi/lsp-client.json, so a slow server can be given more headroom without changing the defaults for every other server.
  • Global defaults (REQUEST_TIMEOUT_MS = 15s, INIT_TIMEOUT_MS = 60s) are unchanged; overrides are opt-in per server and fall back to the defaults when omitted.

Changes

  • src/lsp/types.ts: add requestTimeoutMs? / initTimeoutMs? to LspServerConfig / ResolvedServer.
  • src/lsp/config-loader.ts: parse the two new fields from LspEntry into the resolved server config.
  • src/lsp/transport.ts: sendRequest now uses this.server.requestTimeoutMs ?? REQUEST_TIMEOUT_MS.
  • src/lsp/manager.ts: track initTimeoutMs per managed client so the idle reaper and warmup path respect an override instead of the fixed manager-wide value.
  • README.md: document the new fields with a kotlin-language-server example.

Test plan

  • npm run check (tsgo + biome) passes
  • npm test passes: 81/81 (77 existing + 4 new)
    • test/manager.test.ts: override longer/shorter than manager default, reaper behavior in each case
    • test/transport.test.ts: new UnresponsiveHarness covers default timeout and a longer override not firing early

Summary by cubic

Allows per-server overrides for request and init timeouts so slow LSP servers (e.g. kotlin-language-server on a large multi-module Gradle project) don't spuriously time out against the global 15s/60s defaults.

  • Adds optional requestTimeoutMs / initTimeoutMs fields to a server entry in .pi/lsp-client.json / ~/.pi/lsp-client.json; only finite positive numbers are accepted, anything else is ignored.
  • Fixes propagation so the overrides reach the transport's request timeout and the manager's init reaper and warmup paths.
  • Overrides fall back to the global defaults when omitted; the defaults stay unchanged.