We have a (internal) VS Code extension implementing the Language Server Protocol for a language. I've checked out the VS Code LS sample to enable debugging on the server, however in the sample, the ServerOptions
used to initialize the LanguageClient
is always a type:
{
run: NodeModule;
debug: NodeModule;
}
And here an inspect argument with a port number can be explicitly passed in to the client, which can then be used to debug.
In our project, we are already using the (() => Promise<StreamInfo>)
version of the ServerOptions
type, which of course doesn't provide a mechanism to pass in the arguments to start the service with debugging available at a specific port.
To start the language server, we later call into child_process.spawn(command, args, options)
with some args to kick off the server process. Here the command
is node
, args
is ["path/to/server/main.js", "path/to/log/output" ]
, options
is:
{
"cwd":"path/to/workspace/folder",
"env":{/*various environment propreties, including a hostname, but no port*/}
}
I assume there is a specific argument/env variable we should be passing in at this point to make the server debuggable? What can I pass in here to listen for the debugger on a given port?
Note: we are leveraging vscode-remote, but I don't think that should impact the answer (besides making sure the port used is open on the remote machine).
The mechanism I found is to add "--inspect" as the first argument to args
in child_process.spawn(...)
, so args
now has the value:
["--inspect", "path/to/server/main.js", "path/to/log/output"]
This launches the debug listener on the default node port (9229) on 127.0.0.1