Skip to content

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

@DanTup

Description

@DanTup

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:

public needsStop(): boolean {
return this.$state === ClientState.Starting || this.$state === ClientState.Running;
}

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue identified by VS Code Team member as probable bug

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions