Skip to content

Commit ecdfec1

Browse files
authored
fix(lsp): prevent infinite loop on EOF (#15)
* fix(lsp): prevent infinite loop on EOF in header reading When stdin reaches EOF, read_line returns an empty string. The loop only checked for "\r\n" or "\n" to break, causing infinite warnings when running mcpls manually without proper MCP input. Now returns ServerTerminated error on EOF, breaking the loop cleanly. * docs: add rust-analyzer installation prerequisites * chore(release): prepare v0.2.1 - Bump version to 0.2.1 - Update CHANGELOG with bug fix and docs improvements
1 parent 6c956cd commit ecdfec1

5 files changed

Lines changed: 43 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.2.1] - 2025-12-27
11+
12+
Patch release with bug fix and documentation improvements.
13+
14+
### Fixed
15+
16+
- **Infinite loop on EOF** — Fixed infinite warning loop when LSP server terminates or stdin reaches EOF. Now returns `ServerTerminated` error cleanly instead of flooding logs with "Malformed header" warnings.
17+
18+
### Added
19+
20+
- **Prerequisites section in README** — Added rust-analyzer installation instructions with multiple methods (rustup, Homebrew, package managers). Includes important note about "LSP server process terminated unexpectedly" error when language server is missing.
21+
1022
## [0.2.0] - 2025-12-27
1123

1224
Enhanced LSP features release with 5 new MCP tools for advanced code intelligence.
@@ -276,6 +288,7 @@ Add to `~/.claude/mcp.json`:
276288
- Workspace auto-discovery
277289
- LSP server auto-detection and installation
278290

279-
[Unreleased]: https://github.com/bug-ops/mcpls/compare/v0.2.0...HEAD
291+
[Unreleased]: https://github.com/bug-ops/mcpls/compare/v0.2.1...HEAD
292+
[0.2.1]: https://github.com/bug-ops/mcpls/compare/v0.2.0...v0.2.1
280293
[0.2.0]: https://github.com/bug-ops/mcpls/compare/v0.1.0...v0.2.0
281294
[0.1.0]: https://github.com/bug-ops/mcpls/releases/tag/v0.1.0

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ members = ["crates/*"]
33
resolver = "2"
44

55
[workspace.package]
6-
version = "0.2.0"
6+
version = "0.2.1"
77
edition = "2024"
88
rust-version = "1.85"
99
authors = ["Andrei G. <k05h31@gmail.com>"]
@@ -23,7 +23,7 @@ clap = "4.5"
2323
dirs = "6.0"
2424
futures = "0.3"
2525
lsp-types = "0.97"
26-
mcpls-core = { path = "crates/mcpls-core", version = "0.2.0" }
26+
mcpls-core = { path = "crates/mcpls-core", version = "0.2.1" }
2727
predicates = "3.1"
2828
rmcp = "0.12"
2929
rstest = "0.26"

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,26 @@ AI coding assistants are remarkably capable, but they're working blind. They see
2424
- **Safe refactoring** — Rename symbols with confidence, workspace-wide
2525

2626
> [!TIP]
27-
> Zero configuration for Rust projects. Just install and go — rust-analyzer works out of the box.
27+
> Zero configuration for Rust projects. Just install mcpls and a language server — ready to go.
28+
29+
## Prerequisites
30+
31+
For Rust projects, install rust-analyzer:
32+
33+
```bash
34+
# Via rustup (recommended)
35+
rustup component add rust-analyzer
36+
37+
# Or via Homebrew (macOS)
38+
brew install rust-analyzer
39+
40+
# Or via package manager (Linux)
41+
# Ubuntu/Debian: sudo apt install rust-analyzer
42+
# Arch: sudo pacman -S rust-analyzer
43+
```
44+
45+
> [!IMPORTANT]
46+
> mcpls requires a language server to be installed. Without rust-analyzer, you'll see "LSP server process terminated unexpectedly" errors.
2847
2948
## Installation
3049

crates/mcpls-core/src/lsp/transport.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ impl LspTransport {
118118
line.clear();
119119
self.stdout.read_line(&mut line).await?;
120120

121+
// EOF - stream closed
122+
if line.is_empty() {
123+
return Err(Error::ServerTerminated);
124+
}
125+
121126
if line == "\r\n" || line == "\n" {
122127
break;
123128
}

0 commit comments

Comments
 (0)