question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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)

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:5
  • Comments:18 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
theAkitocommented, Jul 11, 2020

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):

  1. Explicitly install openjdk-14-jdk-headless on WSL2.
  2. Change 2 configurations below Kotlin > Language Server: Port: 5050 Kotlin > Language Server: Transport: tcp

  3. Install Kotlin compiler.
curl -sSLOf https://github.com/JetBrains/kotlin/releases/download/v1.3.72/kotlin-native-linux-1.3.72.tar.gz
tar zxf kotlin-native-linux-1.3.72.tar.gz
sudo mv kotlin-native-linux-1.3.72 /usr/bin/kotlin-native-linux-1.3.72
export PATH="$PATH:/usr/bin/kotlin-native-linux-1.3.72/bin" # Optionally, add to .bashrc or something.
which kotlinc # Check if it works.
  1. Restart VS Code.

Now the language server starts up properly.

WSL2’s OS: Debian Linux bullseye

1reaction
colorhaakecommented, Dec 20, 2019

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:

/** Searches the folder for all build-files. */
private fun folderResolvers(workspaceRoot: Path, folder: Path, ignored: List<PathMatcher>): Collection<ClassPathResolver> {
    var resolvers = mutableListOf<ClassPathResolver>()

    for (file in Files.list(folder)) {
        // Only test whether non-ignored file is a build-file
        if (ignored.none { it.matches(workspaceRoot.relativize(file)) }) {
            val resolver = asClassPathProvider(file)
            if (resolver != null) {
                resolvers.add(resolver)
                break
            } else if (Files.isDirectory(file)) {
                resolvers.addAll(folderResolvers(workspaceRoot, file, ignored))
            }
        }
    }

    return resolvers
}

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Language Support for Java server crashed 5 times in the ...
The Language Support for Java server crashed 5 times in the last 3 minutes. The server will not be restarted · The problem...
Read more >
The Kotlin Language Client server crashed 5 times in the last ...
The Kotlin Language Client server crashed 5 times in the last 3 minutes. The server will not be restarted.
Read more >
Flutter/Kotlin/Gradle Unsupported class file in VS Code
The Kotlin Language Client server crashed 5 times in the last 3 minutes. The server will not be restarted. …and in the Output...
Read more >
The language server crashed 5 times in the last 3 minutes. In c ...
I worked on a medium sized C project and at times it became so slow that I constantly have to restart VSCode. Check...
Read more >
Server Down: What to Do When My Server Crashes?
So, a little disclaimer, providing solutions to every type of server crash is not within the scope of this article. What this tutorial...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found