EmmyLua / EmmyLua-LanguageServer

153 stars 28 forks source link

Missing Content-Length header #21

Closed wbthomason closed 4 years ago

wbthomason commented 4 years ago

When using the latest version of the server with https://github.com/neoclide/coc.nvim, I get the following error and no functionality works:

[coc.nvim] error: Uncaught exception: Error: Header must provide a Content-Length property.
    at StreamMessageReader.onData (/home/wil/dotfiles/neovim/.config/nvim/pack/minpac/start/coc.nvim/node_modules/vscode-jsonrpc/lib/messageReader.js:163:27)
    at Socket.<anonymous> (/home/wil/dotfiles/neovim/.config/nvim/pack/minpac/start/coc.nvim/node_modules/vscode-jsonrpc/lib/messageReader.js:148:18)
    at Socket.emit (events.js:210:5)
    at addChunk (_stream_readable.js:308:12)
    at readableAddChunk (_stream_readable.js:289:11)
    at Socket.Readable.push (_stream_readable.js:223:10)
    at Pipe.onStreamRead (internal/stream_base_commons.js:182:23)

From the stack trace here, it seems like the server is not sending well-formed messages to the client. Should this server still work with standard LSP clients? I should note that running the server the same way coc.nvim is configured to run it appears to work (it does not produce errors and waits for input), and coc.nvim is working with other servers, so I don't think this is a misconfiguration.

tangzx commented 4 years ago

emmylua-ls works fine with vscode/sublime..., may be its not an issue of emmylua-ls ? btw: emmylua-ls use lsp4j

wbthomason commented 4 years ago

Hmm, ok. Thanks, that's useful to know. I'll check in with the coc.nvim project. It looks like lsp4j has some known differences of behavior around specifically the Content-Length header, e.g. https://github.com/eclipse/lsp4j/issues/210, so it might be an issue with them, too. Probably not an EmmyLua issue, though. Thank you!

wbthomason commented 4 years ago

Sorry to reopen this issue, but I just recovered this stacktrace:

Nov 02, 2019 11:29:16 PM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint handleNotification
WARNING: Notification threw an exception: {
  "jsonrpc": "2.0",
  "method": "initialized",
  "params": {}
}
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:67)
    at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.notify(GenericEndpoint.java:152)
    at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleNotification(RemoteEndpoint.java:220)
    at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:187)
    at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:192)
    at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
    at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:99)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:514)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:844)
Caused by: java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
    ... 11 more
Caused by: java.lang.IllegalArgumentException: URLDecoder: Illegal hex characters in escape (%) pattern - Error at index 0 in: "ng"
    at java.base/java.net.URLDecoder.decode(URLDecoder.java:232)
    at java.base/java.net.URLDecoder.decode(URLDecoder.java:142)
    at com.tang.lsp.FileURIKt.decodeURL(FileURI.kt:10)
    at com.tang.lsp.FileURIKt.access$decodeURL(FileURI.kt:1)
    at com.tang.lsp.FileURI$_nameParts$2.invoke(FileURI.kt:66)
    at com.tang.lsp.FileURI$_nameParts$2.invoke(FileURI.kt:23)
    at kotlin.SynchronizedLazyImpl.getValue(Lazy.kt:131)
    at com.tang.lsp.FileURI.get_nameParts(FileURI.kt)
    at com.tang.lsp.FileURI.getName(FileURI.kt:71)
    at com.tang.vscode.WorkspaceRootFileScopeProvider.isInclude(WorkspaceRootFileScopeProvider.kt:33)
    at com.tang.intellij.lua.fs.FileManager.isInclude(fileManager.kt:59)
    at com.tang.intellij.lua.fs.FileManager.isInclude(fileManager.kt:55)
    at com.tang.intellij.lua.fs.FileManager.collectFiles(fileManager.kt:82)
    at com.tang.intellij.lua.fs.FileManager.collectFiles(fileManager.kt:85)
    at com.tang.intellij.lua.fs.FileManager.collectFiles(fileManager.kt:85)
    at com.tang.intellij.lua.fs.FileManager.collectFiles(fileManager.kt:85)
    at com.tang.intellij.lua.fs.FileManager.collectFiles(fileManager.kt:85)
    at com.tang.intellij.lua.fs.FileManager.collectFiles(fileManager.kt:85)
    at com.tang.intellij.lua.fs.FileManager.collectFiles(fileManager.kt:85)
    at com.tang.intellij.lua.fs.FileManager.collectFiles(fileManager.kt:85)
    at com.tang.intellij.lua.fs.FileManager.collectFiles(fileManager.kt:85)
    at com.tang.intellij.lua.fs.FileManager.collectFiles(fileManager.kt:85)
    at com.tang.intellij.lua.fs.FileManager.collectFiles(fileManager.kt:85)
    at com.tang.vscode.WorkspaceRootFileScopeProvider.findAllFiles(WorkspaceRootFileScopeProvider.kt:49)
    at com.tang.intellij.lua.fs.FileManager.findAllFiles(fileManager.kt:69)
    at com.tang.vscode.LuaWorkspaceService.loadWorkspace(LuaWorkspaceService.kt:229)
    at com.tang.vscode.LuaWorkspaceService.loadWorkspace(LuaWorkspaceService.kt:214)
    at com.tang.vscode.LuaLanguageServer.initialized(LuaLanguageServer.kt:118)
    ... 16 more

That seems to imply that the issue might be with EmmyLua after all? Is there any further debugging info I could provide to help track down the problem, if indeed it is in EmmyLua?

ZSaberLv0 commented 4 years ago

same issue, tested with many LSP plugins of vim/neovim, any way to resolve this?

CGNonofr commented 4 years ago

It seems that the server print things not related to lsp on stdout (at least when a file is open)

In my case:

[+] file:/tmp/project/main.lua

between 2 messages

Maybe some implementations are able to ignore it until they found a Content-Length

The bug exists since the release 0.3.1

ZSaberLv0 commented 4 years ago

22 did solve the issue for my case, thanks

CGNonofr commented 4 years ago

Can we release this fix?

tangzx commented 4 years ago

v0.3.5