microsoft / microsoft/vscode-languageserver-node

client.needsStop() and client.stop() disagree on whether it's valid to call stop()

Open
#1,559 6 comments 1 reaction 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 trying to fix some issues with the LSP client showing errors when I try to dispose it. One issue is that I'm getting errors like this:

rejected promise not handled within 1 second: Error: Client is not running and can't be stopped. It's current state is: starting
extensionHostProcess.js:155
stack trace: Error: Client is not running and can't be stopped. It's current state is: starting
	at LanguageClient.shutdown (d:\Dev\Dart-Code\Dart-Code\out\dist\extension.js:38362:10)
	at LanguageClient.stop (d:\Dev\Dart-Code\Dart-Code\out\dist\extension.js:38332:15)
	at LanguageClient.stop (d:\Dev\Dart-Code\Dart-Code\out\dist\extension.js:47462:22)
	at Object.dispose (d:\Dev\Dart-Code\Dart-Code\out\dist\extension.js:4810:66)
	at disposeAll (d:\Dev\Dart-Code\Dart-Code\out\dist\extension.js:29122:20)
	at LspAnalyzer.dispose (d:\Dev\Dart-Code\Dart-Code\out\dist\extension.js:25645:32)
	at d:\Dev\Dart-Code\Dart-Code\out\dist\extension.js:14511:36
	at tryCleanup (d:\Dev\Dart-Code\Dart-Code\out\dist\extension.js:14544:15)

The problem is that calling stop() is invalid when the state is stopping, however my code looks like this:

if (this.client.needsStop())
	await this.client.stop();

The implementation of needsStop is:

https://github.com/microsoft/vscode-languageserver-node/blob/f58f4dff16ad2760028bb1cb95e882de30a1000f/client/src/common/client.ts#L1228-L1230

So needsStop says that stop is required if the state is starting, but calling stop() throws. It's not clear to me what the correct way of shutting down the server cleanly is.

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 in client/src/common/client.ts at needsStop and stop, then trace the client state transitions involved when disposal occurs during starting or stopping. Reproduce the mismatch described in the issue and inspect existing client tests if present. Done means the stop decision and stop behavior agree, with coverage for the reported lifecycle 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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.