Repository navigation
feat: allow per-server request/init timeout overrides - #5
Conversation
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 for, causing spurious timeouts even though the server would have responded given more time. Add optional `requestTimeoutMs` and `initTimeoutMs` fields to server entries 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.
|
@code-yeongyu, I referenced this repository during the LSP configuration on my Pi agent. In the process, I needed to modify the timeout parameter; I am submitting a pull request that refactors this value into a configurable variable. Thank you for your work. |
code-yeongyu
left a comment
There was a problem hiding this comment.
Thanks for this - per-server timeouts are a good fit, and the manager and transport changes plus the reaper tests look right. I reviewed it against the head commit (da398a6) and found three problems. Because maintainer edits are enabled, I'm pushing a follow-up commit to this branch rather than asking you for another round:
src/lsp/server-resolution.ts:13-20:findServerForExtension()rebuilds theResolvedServerfield by field and doesn't copyrequestTimeoutMsorinitTimeoutMs. Every LSP tool acquires its server through this function, so neither override ever reachesLspManager.getClient()orLspClientTransport.sendRequest()in practice. The new manager and transport tests pass only because they construct the server directly. Fix: carry both fields through, plus a test that goes from a config file tofindServerForExtension().src/lsp/config-loader.ts:87-88: the values are passed through without validation. With0, a negative number, or a string like"90000",setTimeoutfires almost immediately (Node clamps non-positive or non-numeric delays to 1ms), so every request would time out at once. Fix: accept only finite positive numbers and ignore anything else, so the default applies.README.md:174-175: the example adds//comments inside the config block, butloadJsonFile()(src/lsp/config-loader.ts:40) uses plainJSON.parseand silently returnsnullon a parse error. A user who copies the example would lose the entire project config without any error. Fix: remove the comments, label the blockjson, and document the validation rule.
Not blocking: /lsp warmup (src/index.ts:283-297) still resolves ids only from the builtin list, so it ignores custom servers and their overrides. That is issue #4, and I'm fixing it separately in the dependency refresh PR.
findServerForExtension() dropped requestTimeoutMs/initTimeoutMs, so the overrides never reached the manager or transport on the tool path. Accept only finite positive numbers from config and drop comments from the README example because the config file is parsed as plain JSON.
|
CI on 77738ec: both node 22 cells pass (ubuntu, macos). The two node 20 cells fail with |
|
Correction: this repository allows only merge commits (squash is disabled), and the required checks still list the node 20 cells that fail on main for the reason above. I'm merging with a merge commit and an admin override for those two pre-existing failures. Your commit keeps your authorship. |
Summary
kotlin-language-serveron a multi-module Gradle project) take far longer to answerinitializeor individual requests than the global defaults (60s / 15s) allow, causing spurious timeouts even though the server would eventually respond.requestTimeoutMs/initTimeoutMsfields 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.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: addrequestTimeoutMs?/initTimeoutMs?toLspServerConfig/ResolvedServer.src/lsp/config-loader.ts: parse the two new fields fromLspEntryinto the resolved server config.src/lsp/transport.ts:sendRequestnow usesthis.server.requestTimeoutMs ?? REQUEST_TIMEOUT_MS.src/lsp/manager.ts: trackinitTimeoutMsper 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 akotlin-language-serverexample.Test plan
npm run check(tsgo + biome) passesnpm testpasses: 81/81 (77 existing + 4 new)test/manager.test.ts: override longer/shorter than manager default, reaper behavior in each casetest/transport.test.ts: newUnresponsiveHarnesscovers default timeout and a longer override not firing earlySummary by cubic
Allows per-server overrides for request and init timeouts so slow LSP servers (e.g.
kotlin-language-serveron a large multi-module Gradle project) don't spuriously time out against the global 15s/60s defaults.requestTimeoutMs/initTimeoutMsfields to a server entry in.pi/lsp-client.json/~/.pi/lsp-client.json; only finite positive numbers are accepted, anything else is ignored.Written for commit 77738ec. Summary will update on new commits.