Repository navigation
fix(lsp): report a start that exits in the same turn as the next call - #101
Conversation
Address the last review notes on the server-exit change. The exit handler marked a starting server crashed at once, but its start failed one event-loop turn later, when markGone ran. A call in that turn found the server crashed with no stored error, started a second server, and the first start's reason was never reported. A server still starting now stays "starting" until its start fails, and the start's handler marks it crashed together with the error to report. A test calls ensureServer on every turn and expects the exit text and one spawn. Start failures read "Failed to start" instead of "Failed to spawn": the server may have spawned and then exited or missed the initialize bound. Design spec 3.9 (SERVER_NOT_AVAILABLE), 5.5 and 8 now mention the delayed report, and the pending changeset names the missed initialize bound.
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: c84cc0ce-bdc9-4689-bd88-65f455376bd6) |
There was a problem hiding this comment.
This is an auto review done by revuto.
Revuto completed the review and found no evidence-backed concerns.
|
Verdict: ready to land. The exit-turn fix works, the new test fails on Non-blocking1. The 2. The new comment is exact for exits and spawn errors, not for broken pipes. 3. The Rust port still says "Failed to spawn". The fix, path by pathProbes against the built
The spawn-error row is only reachable from a tick right after the Through the Stored report, concurrency, close
What I ran
|
…n Rust The SERVER_NOT_AVAILABLE row, section 5.3 and the changeset now also name a pipe that breaks during the start and an error reply to initialize. The spawn-client comment says how a broken pipe reaches the crashed state, and the Rust port reports a start failure as Failed to start, like the TypeScript client.
|
Addressed the three notes in d0556f9 (text only, plus the Rust message):
Ran |
There was a problem hiding this comment.
This is an auto review done by revuto.
Revuto completed the review and found no evidence-backed concerns.
Follow-up to #95, from the last review's non-blocking notes (#95 (comment)).
1. A start that exits in the same turn as the next call
The exit handler marked a starting server crashed at once, but its start failed one event-loop turn later, when
markGoneran fromsetImmediate. A call that reachedensureServerin that turn found the server crashed with no stored error. It started a second server, and the first start's reason was never reported.A server still starting now stays
startinguntil its start fails. The start's own handler marks it crashed together with the error to report, so no call sees it crashed without that error. A call in that turn getsserver_starting, and the next one gets the report.Test: abort the first
ensureServerat once, then callensureServeron everysetImmediateturn against a server that exits with code 3 duringinitialize. It expects the exit error with the stderr text and one spawn.2. Spec and changeset
SERVER_NOT_AVAILABLE: also when the server could not start (spawn error, exit duringinitialize, noinitializeanswer within the bound), including the once-only delayed report.SERVER_NOT_AVAILABLEwhen the start failed meanwhile.lsp-server-exitchangeset now names the missedinitializebound as a reported reason.3. "Failed to start", not "Failed to spawn"
Every start failure was prefixed "Failed to spawn", even when the server spawned and then exited or missed the
initializebound. It now reads "Failed to start". No test pinned the old text. The background-exit test now asserts the full prefix, so it fails on main.Checks
pnpm test:dependencies,pnpm lint:harnessandturbo run build typecheck testwithout harness-e2e pass (39 of 39 tasks, 61 harness-lsp tests).cargo test --workspace --lockedpasses (278, no Rust changes). The spawn-client file (32 tests) passed 20 of 20 runs idle and 25 of 25 pinned to one CPU.lsp-transport.test.tsagainst typescript-language-server passed 30 of 30 idle and 30 of 30 pinned, with no unhandled error. Nothing was written to/tmp.Note
Medium Risk
Touches LSP spawn lifecycle and error reporting timing; wrong state transitions could still cause duplicate spawns or lost failure reasons, though behavior is heavily covered by spawn-client tests.
Overview
Fixes a race in
createSpawnLspClient: on processexitduringinitialize, the client used to flip internal state tocrashedimmediately while the real failure (stderr +LspServerExitedError) was deferred to the next event-loop turn viasetImmediate. AensureServercall in that gap saw a crashed entry with no stored start error, spawned a second server, and never surfaced the first failure.Behavior change:
markCrashednow leaves a serverstartinguntil the start promise fails and recordsunreportedStartError. Calls in the gap getserver_starting(or the stored error on the next call), not a duplicate spawn. User-facing copy switches "Failed to spawn" → "Failed to start" in the TS and Rustlsporchestrators.Docs/changesets:
agent-knowledge/design/lsp.mdand changesets documentSERVER_NOT_AVAILABLEfor delayed start failures (including same-turn exit) and theinitializetimeout as a reported reason. A new patch changeset captures this follow-up.Reviewed by Cursor Bugbot for commit d0556f9. Configure here.