microsoft / microsoft/vscode-languageserver-node

Catching unhandled exceptions when starting language server by LanguageClient

Open
#1,307 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature-request help wanted
Dominant language
TypeScript
Stars
1.8k
Forks
404
Avg merge
2d 8h
Merged PRs (30d)
14

Description

When starting a language server (in my case python), which fails, there are a few exceptions that cannot be caught:

Error: Pending response rejected since connection got disposed
at Object.dispose (...\dist\extension.js:8861:27)
at Object.dispose (...\dist\extension.js:5418:35)
at LanguageClient.handleConnectionClosed (...\dist\extension.js:5009:34)
at LanguageClient.handleConnectionClosed (...\dist\extension.js:3447:22)
at closeHandler (...\dist\extension.js:4996:18)
at CallbackList.invoke (...\dist\extension.js:6843:39)
at Emitter.fire (...\dist\extension.js:6905:36)
at closeHandler (...\dist\extension.js:8008:26)
at CallbackList.invoke (...\dist\extension.js:6843:39)
at Emitter.fire (...\dist\extension.js:6905:36)
at StreamMessageWriter.fireClose (...\dist\extension.js:7455:27)
at Socket.<anonymous> (...\dist\extension.js:7487:42)
at Socket.emit (node:events:513:28)
at Pipe.<anonymous> (node:net:757:14)
Error: Client is not running and can't be stopped. It's current state is: starting
at LanguageClient.shutdown (...\dist\extension.js:4818:19)
at LanguageClient.stop (...\dist\extension.js:4789:21)
at LanguageClient.stop (...\dist\extension.js:3417:22)
at LanguageClient.doInitialize (...\dist\extension.js:4771:27)
at async LanguageClient.start (...\dist\extension.js:4626:13)
at async restartServer (...\dist\extension.js:440:9)
at async ...\dist\extension.js:50:20

The problem is that VSCode for all unhandled errors creates an "unhandledError" telemetry event. For correct analysis of telemetry data, you must manually create an event that indicates a specific problem. In this case, for example, "serverStartFailed".

Yes, I can set initializationFailedHandler in the LanguageClientOptions and create the necessary telemetry event in it. But VSCode will still create a duplicate "unhandledError" event, because the error is not caught.

Another bewilderment is that the server's stderr output can only be received in the outputChannel. Why not pass it as an argument to initializationFailedHandler? Or create a corresponding attribute in the LanguageClient class? To understand what happened to the user, I need to send all the information from the outputChannel to the telemetry server, including unnecessary information.

It also looks strange to automatically try to stop a server that is not running, which leads to another error. And it also automatically sent to telemetry...

Thanks!

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 from the LanguageClient initialization and stop paths shown in the stack traces, then inspect initializationFailedHandler and how server stderr reaches outputChannel. Reproduce a language-server startup failure and verify that it does not produce duplicate unhandled-error telemetry or a second stop error, while the failure details remain available to the handler.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
backend-api-design, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.