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.
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
exitandinitialize.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
shutdownto for example kill workers. Both handlers override each other.