kotlin-language-server: The Kotlin Language Server server crashed 5 times in the last 3 minutes. The server will not be restarted.
I have just installed this extension in VS Code Insiders 1.26.0 on a Windows 10 x64 machine. However, when opening Kotlin projects, I get the message I put in the title. The Kotlin output window only shows this:
[Info - 9:52:56 AM] Connection to server got closed. Server will restart.
[Info - 9:52:56 AM] Connection to server got closed. Server will restart.
[Info - 9:52:56 AM] Connection to server got closed. Server will restart.
[Info - 9:52:56 AM] Connection to server got closed. Server will restart.
[Error - 9:52:56 AM] Connection to server got closed. Server will not be restarted.
And when looking in DevTools, I see this:
ERR Message header must separate key and value using :: Error: Message header must separate key and value using :
at C:\Users\Noah\.vscode-insiders\extensions\fwcd.kotlin-0.1.7\node_modules\vscode-jsonrpc\lib\messageReader.js:68:23
at Array.forEach (<anonymous>)
at MessageBuffer.tryReadHeaders (C:\Users\Noah\.vscode-insiders\extensions\fwcd.kotlin-0.1.7\node_modules\vscode-jsonrpc\lib\messageReader.js:65:17)
at StreamMessageReader.onData (C:\Users\Noah\.vscode-insiders\extensions\fwcd.kotlin-0.1.7\node_modules\vscode-jsonrpc\lib\messageReader.js:194:43)
at Socket.<anonymous> (C:\Users\Noah\.vscode-insiders\extensions\fwcd.kotlin-0.1.7\node_modules\vscode-jsonrpc\lib\messageReader.js:185:19)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
at Socket.Readable.push (_stream_readable.js:208:10)
at Pipe.onread (net.js:594:20)
That message is repeated 4 or 5 times in fast succession. Any solutions to this?
C:\Users\Noah\Desktop\kotlin> java -version
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
C:\Users\Noah\Desktop\kotlin> kotlin -version
Kotlin version 1.2.60-eap-75 (JRE 1.8.0_151-b12)
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 5
- Comments: 19 (3 by maintainers)
I experienced this issue on VS Code with WSL2. I have installed the extension within WSL2 and tried to use it on Windows 10 2004. What I did (in part based on @Polarbear08’s solution):
openjdk-14-jdk-headless
on WSL2.Now the language server starts up properly.
WSL2’s OS: Debian Linux bullseye
I have the same issue. My project is a huge android project with hundreds of modules and it has at least 15000 Kotlin files.
After tracing the source codes, I found the Kotlin Language Server failed on the following method:
https://github.com/fwcd/kotlin-language-server/blob/master/shared/src/main/kotlin/org/javacs/kt/classpath/DefaultClassPathResolver.kt#L22
This method is looking for all the maven / gradle / shell modules from the project root to its subfolder recursively. For example, it searches all of “.build.gradle" or ".build.gradle.kts” to identify it is gradle module or not. The reason to do that is it wants to resolve the dependencies on each maven / gradle / shell module. But this search takes too much time, especially for the huge project. Although it ignores not necessary folders from the project root’s “.gitignore”, it still causes the Kotlin Language Server failed. My android project has a flat structure and it only has two layers of structure. So it doesn’t need to search so deeply. I modify this method to only run two levels of recursion and this modification works for my project. But this solution only works for your projects has two layers of the structure. I have not idea how to traverse the project trees efficiently to resolve all of the dependencies.
We have a mix of node/Kotlin code in our monorepo (and we’re using yarn workspaces so the root node_modules tends to contain pretty much everything), but the thing that’s weird is it works on some machines and not others. Without better error diagnostics it’s really hard to know where to continue to look
I’m seeing the same error on OSX, what’s strange is as far as I can tell my environment is the same as a coworker’s and his is running with no issues.
The Kotlin diagnostic output doesn’t show much, I just get the following 5 times and then it quits:
Is there a way to get additional debugging info regarding why the language server is shutting down?
The error actually occurred because my JAVA_HOME was set but to the wrong location. Probably a lot more fringe than I initially thought so it’s probably not the same issues others are having.
Had the same error. I went and changed the source code on
messageReader.js
toconsole.log
the header since it seemed to be causing the problem. It returned an array containing this:Whoops. Setting the java home environment variable fixed the problem. Maybe it’s possible to throw a better error message? I think the issue can be closed unless the original person comes back and says they’re still having issues.
Tested on Linux and there was no issue so this seems to be a windows only issue. Also hi another Noah!