microsoft / microsoft/vscode-languageserver-node

LanguageClient get stuck in starting state with socket transport kind

Open
#1,586 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
1.8k
Forks
404
Avg merge
2d 8h
Merged PRs (30d)
14

Description

I'm writing an LSP extension that uses socket transport kind.
When the command in the server option exits with a nonnull code, the LanguageClient gets stuck in start().

const serverOptions = {
	"command": "node",
	"args": ["-e", "process.exit(42)"],
	transport: {
		kind: TransportKind.socket,
		port: 8080
	}
}
const clientOptions = {}

lspClient = new LanguageClient(
	"MylanguageServer",
	"My Language Server",
	serverOptions,
	clientOptions
);

lspClient.onDidChangeState((state) => {
	const states = ["Stopped", "Running", "Starting"];
	console.log(`State change from ${states[state.oldState-1]} to ${states[state.newState-1]}`)
})

lspClient.start();

I expect that the start fails if the command fails.
I tried to investigate. The start() seems to be waiting for a connection before registering on the exit event of the spawned process.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the provided socket-transport example and tracing LanguageClient.start() through the spawned process and connection wait. Check how a nonzero command exit is handled, then verify that start fails instead of remaining in the Starting state.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.