Skip to content

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

@kapral18

Description

@kapral18

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
npm ci
  1. Build
npm run build
  1. Run this repro (4s timeout):
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions