From 0b2810644d96f9b7c0a37a52ed8b4f7fac8f111e Mon Sep 17 00:00:00 2001 From: Guoliang Chen Date: Sat, 29 Aug 2026 02:48:32 -0700 Subject: [PATCH] Hotfix: --stdio is accepted, because real VS Code sessions send it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit vscode-languageclient appends --stdio for TransportKind.stdio — the spawn the shipped extension actually makes — and the --verbose round's strict argument parser refused it: exit 2, five crashes, the client gives up. Nothing in the loop caught it because smoke.js and the restart harness spawn the binary directly, never through the library. --stdio now parses as the statement of fact it is (stdio is the only transport), in every combination, changing nothing; near misses and 真 unknown args still exit 2 with the usage line, which now names both flags. smoke.js spawns with --stdio so the library's real spawn shape stays covered from here on. Found live by the owner installing the hierarchy preview build. Co-Authored-By: Claude Fable 5 --- crates/lucisv_server/src/main.rs | 26 +++++++++++++++++++++++++- docs/features/lucisv-server/README.md | 3 ++- editors/vscode/smoke.js | 6 +++++- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/crates/lucisv_server/src/main.rs b/crates/lucisv_server/src/main.rs index a5ce863..251121e 100644 --- a/crates/lucisv_server/src/main.rs +++ b/crates/lucisv_server/src/main.rs @@ -73,10 +73,17 @@ use crate::uri::uri_to_path; /// log channel. One spelling, no `-v` — see /// `docs/features/verbose-timing/README.md`. const VERBOSE: &str = "--verbose"; +/// `vscode-languageclient` (and other LSP clients) append `--stdio` to the +/// spawn when the transport is stdio — the only transport this server has. +/// Accepted as the statement of fact it is; rejecting it turned out to crash +/// every real VS Code session the moment strict argument parsing shipped +/// (lead hotfix, 2026-08-29 — the smoke and restart harnesses spawn the +/// binary directly, so nothing in the loop exercised the library's spawn). +const STDIO: &str = "--stdio"; /// What someone who spelled an argument wrong is told, on stderr. One line: /// this binary is spawned by an editor, not typed at a prompt. -const USAGE: &str = "usage: lucisv-server [--verbose]"; +const USAGE: &str = "usage: lucisv-server [--verbose] [--stdio]"; fn main() -> Result<(), Box> { // Before the transport: an argument we do not understand means the client @@ -146,6 +153,9 @@ fn main() -> Result<(), Box> { fn verbose_flag(args: impl Iterator) -> Result { let mut verbose = false; for arg in args { + if arg == STDIO { + continue; + } if arg != VERBOSE { return Err(arg); } @@ -614,6 +624,20 @@ mod tests { } } + #[test] + fn stdio_is_accepted_as_the_statement_of_fact_it_is() { + // `vscode-languageclient` appends `--stdio` for TransportKind.stdio — + // the spawn every real VS Code session actually makes. Rejecting it + // crashed the extension five times and gave up (lead hotfix, + // 2026-08-29); it must parse in every combination and change nothing. + assert_eq!(args(&["--stdio"]), Ok(false)); + assert_eq!(args(&["--stdio", "--verbose"]), Ok(true)); + assert_eq!(args(&["--verbose", "--stdio"]), Ok(true)); + assert_eq!(args(&["--stdio", "--stdio"]), Ok(false)); + // And a near miss of IT is still refused. + assert_eq!(args(&["--Stdio"]), Err("--Stdio".to_string())); + } + #[test] fn the_first_argument_we_do_not_take_is_the_one_reported() { // Named, so the message can say which word was wrong — the whole diff --git a/docs/features/lucisv-server/README.md b/docs/features/lucisv-server/README.md index 6238ef6..62c9df2 100644 --- a/docs/features/lucisv-server/README.md +++ b/docs/features/lucisv-server/README.md @@ -22,7 +22,8 @@ the one `editors/vscode/smoke.js` drives, and it is unchanged. Since |---|---| | *(none)* | The shipped server. Silent unless something is worth saying. | | `--verbose` | Every operation says how long it took, as `timing:` lines in the client's log channel (`window/logMessage`, `MessageType::LOG`). Repeats are idempotent. See `docs/features/verbose-timing/README.md` | -| anything else | `error: unknown option: ` and `usage: lucisv-server [--verbose]` on **stderr**, exit **2** — the CLI's own wording and its "an error occurred" code. Nothing is started | +| `--stdio` | Accepted and changes nothing: stdio is the only transport this server has. It is here because `vscode-languageclient` appends it for `TransportKind.stdio` — the spawn every real VS Code session makes — and rejecting it crashed the extension the moment strict parsing shipped (lead hotfix, 2026-08-29). The smoke and restart harnesses spawn the binary directly, which is why nothing in the loop caught it; `smoke.js` now spawns with `--stdio` so the library's real spawn shape stays covered. | +| anything else | `error: unknown option: ` and `usage: lucisv-server [--verbose] [--stdio]` on **stderr**, exit **2** — the CLI's own wording and its "an error occurred" code. Nothing is started | There is no `-v`, no `--help` and no `--version`: one spelling for the one flag, and the version number lives on the `lucisv` CLI, which is where diff --git a/editors/vscode/smoke.js b/editors/vscode/smoke.js index e51b14b..3a55d19 100644 --- a/editors/vscode/smoke.js +++ b/editors/vscode/smoke.js @@ -47,7 +47,11 @@ function fail(message) { // `lucisv.verbose` — only adds log lines, and is driven by // crates/lucisv_server/tests/e2e.rs; this check stays on the spawn everybody // gets (docs/features/verbose-timing/README.md). -const server = spawn(serverPath, [], { cwd: process.cwd(), env: process.env, stdio: 'pipe' }); +// `--stdio` is what `vscode-languageclient` really appends for +// TransportKind.stdio, so the smoke spawn matches the extension's actual +// spawn — the shape whose absence from this check let strict argument +// parsing ship a server no real VS Code session could start (2026-08-29). +const server = spawn(serverPath, ['--stdio'], { cwd: process.cwd(), env: process.env, stdio: 'pipe' }); server.on('error', (error) => fail(`could not spawn "${serverPath}": ${error.message}`)); const chunks = [];