4

I apologize if I'm a bit low on details here, but the main issue is actually trying to find the problem with my code. I'm updating an older extension of my own that was based on the Language Server example (https://code.visualstudio.com/docs/extensions/example-language-server). I've run into an issue where when I run the client part of my code using F5, and the debug window fires, I get:

The CSSLint Language Client server crashed 5 times in the last 3 minutes. The server will not be restarted.

Ok... so... here's the thing. The problems view in my extension client code shows nothing. DevTools for that Code window shows nothing.

The problems view for my server code shows nothing. DevTools, ditto.

For the Extension Developer Host instance, DevTools does show this:

messageService.ts:126 The CSSLint Language Client server crashed 5 times in the last 3 minutes. The server will not be restarted.e.doShow @ messageService.ts:126

But I can't dig into the details to find a bug. So the question is - assuming that my server code is failing, where exactly would the errors be available?

Gama11
  • 31,714
  • 9
  • 78
  • 100
Raymond Camden
  • 10,661
  • 3
  • 34
  • 68
  • From what I can tell - the issue was with a particular require statement on the server side. I have it running now, but I kinda need to go back to the original code and make it work, which requires me being able to find the error somehow. – Raymond Camden Jan 18 '17 at 23:23

1 Answers1

0

Here is what I usually do to track server crashes down (I assume your server is written in JavaScript / TypeScript).

Use the following server options:

    let serverModule = "path to your server"
let debugOptions = { execArgv: ["--nolazy", "--debug=6009"] };
let serverOptions = {
    run: { module: serverModule, transport: TransportKind.ipc },
    debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions}
};

Key here is to use the TransportKind.ipc. Errors that happen in the server and printed to stdio will then show in the output channel associated to your server (the name of the output channel is the name passed to the LanguageClient)

If you want to debug the server startup / initialize sequence you can change the debugOptions to:

let debugOptions = { execArgv: ["--nolazy", "--debug-brk=6009"] };

If the extension is started in debug mode (e.g. for example launched from VS Code using F5) then the LanguageClient automatically starts the server in debug mode. If the extension is started normally (for example as a real extension in VS Code) then the server is started normally as well.

To make this all work you need a latest version of the LSP node npm module both for server can client (e.g. 2.6.x)

Dirk Bäumer
  • 1,183
  • 9
  • 7
  • So I tried the debug-brk thing you suggested, and in my server code, added: let foo = require2('./csslint'); I then did the build, and in my client code, hit f5, and my third VSCode window pops up. But I see nothing in the client code window. No indication that anything went wrong w/ the server code. – Raymond Camden Jan 20 '17 at 18:47
  • You mentioned you based the Language server of http://code.visualstudio.com/docs/extensions/example-language-server. There are steps in there how to debug the client and the server. If you start the server with --debug-brk it will break on the first statement of the server.js file. So you need to attach a debugger to the server on the port you passed via --debug-brk. This will allow you to step through your server code. Is your project available on GitHub. If so I could have a look and help setting everything. – Dirk Bäumer Jan 20 '17 at 19:29
  • Yep - I'm following that tut - main difference is you used 6009 above and they seem to be using 6004. In terms of order of operation - ctrl+shift+b in server, f5 in client, then f5 in server. Still nothing in console. I can share the code - let me just check in - but be aware it has an intentional bug in server.js to try to help to flesh it it out. – Raymond Camden Jan 20 '17 at 21:41