microsoft / microsoft/vscode-languageserver-node

Allow to register multiple handlers for shutdown

Open
#174 15 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

After spending quite some time today tracking down a bug I noticed the cause was that vscode-languageserver does not allow to register more than one handler for shutdown, and subsequent calls will just override the previous handler silently:

https://sourcegraph.com/github.com/Microsoft/vscode-languageserver-node@fc1a79d05f9c52cbb02d6d172d3e17e1516e59b8/-/blob/server/src/main.ts#L1198:1-1199:1

This seems to also be true for exit and initialize.

I really wonder why the decision was made to provide an event-emitter like interface where you can register handlers at runtime (as opposed to a class/object that provides a single implementation for each method) if you can then only register one method handler for certain (?) methods.

Example use case: You want one connection to proxy or load-balance messages to different other servers. The proxy logic registers a handler for every message to forward them, but the cluster logic also registers a handler to shutdown to for example kill workers. Both handlers override each other.

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 at server/src/main.ts around the shutdown handler registration linked in the issue, then inspect the corresponding registration paths for exit and initialize. Done means multiple handlers can be registered for these events without silently replacing earlier handlers, with behavior covered by the relevant existing tests if available.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
backend-api-design, developer-experience
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 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.