Hotfix: --stdio is accepted, because real VS Code sessions send it
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 <[email protected]>
This commit is contained in:
1 parent
40094c4c4e
commit
0b2810644d
3 files changed
+32
-3
No files matched your search
@@ -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<dyn Error + Sync + Send>> {
|
||||
// Before the transport: an argument we do not understand means the client
|
||||
@@ -146,6 +153,9 @@ fn main() -> Result<(), Box<dyn Error + Sync + Send>> {
|
||||
fn verbose_flag(args: impl Iterator<Item = String>) -> Result<bool, String> {
|
||||
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
|
||||
|
||||
@@ -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: <arg>` 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: <arg>` 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
|
||||
|
||||
@@ -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 = [];
|
||||
|
||||
Reference in new issue
Block a user