elastic / elastic/semantic-code-search-indexer

bug: references command hangs (typescript-language-server stdio wired as IPC)

Open
#138 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
19
Forks
10
PR merge metrics
No merged PRs in 30d

Description

## Problem
`references` relies on `LanguageServerService`, which spawns `typescript-language-server --stdio`, but the connection is constructed with `vscode-jsonrpc` **IPC** readers/writers. This causes the initialize request to never resolve (hang).

## Reproduction
From the repo root:

1) Install deps
```bash
npm ci
```

2) Build
```bash
npm run build
```

3) Run this repro (4s timeout):
```bash
node -e 'const { LanguageServerService } = require("./dist/utils/language_server");
(async()=>{
const svc = new LanguageServerService();
const t = setTimeout(()=>{
console.log("TIMEOUT waiting for initialize (likely transport mismatch)");
try { svc.dispose(); } catch {}
process.exit(0);
}, 4000);

try {
await svc.initialize(process.cwd());
clearTimeout(t);
console.log("initialize resolved (unexpected)");
svc.dispose();
} catch (e) {
clearTimeout(t);
console.log("initialize threw:", e && e.message ? e.message : String(e));
try { svc.dispose(); } catch {}
}
})();'
```

### Expected
`initialize` resolves quickly (or throws a real error if the server can’t start).

### Actual
`initialize` does not resolve within 4 seconds; the script prints:
- `TIMEOUT waiting for initialize (likely transport mismatch)`

## Where in code
- `src/utils/language_server.ts`:
- spawns: `npx typescript-language-server --stdio`
- connects via: `new rpc.IPCMessageReader(this.serverProcess)` / `IPCMessageWriter`

## Suggested fix
Use stdio stream transport:
- Replace IPC reader/writer with stream reader/writer (e.g. `StreamMessageReader` / `StreamMessageWriter`) wired to `serverProcess.stdout` and `serverProcess.stdin`.

Also recommended:
- Handle server start failures and non-zero exit.
- Ensure `dispose()` awaits/handles process termination cleanly.

## Test plan
- Add a lightweight unit/integration test that asserts `initialize()` resolves within a timeout when `typescript-language-server` is available.
- If keeping this optional, update the command to fail fast with a clear error when the binary isn’t present.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in src/utils/language_server.ts and reproduce the hang with npm ci, npm run build, and the provided node command. Trace how the spawned typescript-language-server process is connected and review its initialize and dispose paths. Done means initialize resolves promptly or reports a real startup error, with a lightweight timeout-based test when the server is available.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.