Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while consuming 'textDocument/codeAction' with language server 'Tools for MicroProfile' #521

Open
mfortunat opened this issue Sep 11, 2024 · 16 comments
Labels
bug Something isn't working

Comments

@mfortunat
Copy link

Error while consuming 'textDocument/codeAction' with language server 'Tools for MicroProfile'

org.eclipse.lsp4j.jsonrpc.ResponseErrorException: Internal error.
at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleResponse(RemoteEndpoint.java:209)
at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:193)
at com.redhat.devtools.lsp4ij.LanguageServerWrapper.lambda$start$1(LanguageServerWrapper.java:260)
at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804)
at java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1796)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:507)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1491)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:2073)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:2035)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:187)


IntelliJ IDEA 2024.2.1 (Ultimate Edition)
Build #IU-242.21829.142, built on August 28, 2024


Additional info:

It has already occurred 46 times in the last 2 or 3 days.
Very annoying

@angelozerr
Copy link
Contributor

Do you know how to reproduce it? Have you a sample project?

Could you enable the LSP console trace https://github.com/redhat-developer/lsp4ij/blob/main/docs/UserGuide.md#lsp-console and share the LSP trace when this error occurs.

@mfortunat
Copy link
Author

I attached the log file.
FYI, it generates a new error for each and every cursor move in the code editor; regardless I use the cursor keys or the mouse.

lsp4j-errors.log

@fbricon
Copy link
Contributor

fbricon commented Sep 11, 2024

Do you have the latest versions of LSP4IJ and Quarkus Tools?

@mfortunat
Copy link
Author

LSP4IJ 0.5.0
Quarkus Tools 2.0.2

@angelozerr
Copy link
Contributor

Thanks for the log. The error is very strange, it should send some request like

Here a sample of error:

[Trace - 17:45:56] Sending request 'textDocument/codeAction - (44)'.
Params: {
  "textDocument": {
    "uri": "file:///Users/massimo/Dropbox/Projects/Upwork/Lightwell/McLane/repos/mclanemodern-order-collection-mw/commons/src/main/java/com/mclaneco/oms/commons/exceptions/ModuleAwareException.java"
  },
  "range": {
    "start": {
      "line": 54,
      "character": 49
    },
    "end": {
      "line": 54,
      "character": 49
    }
  },
  "context": {
    "diagnostics": [],
    "triggerKind": 2
  }
}


[Trace - 17:45:56] Received response 'textDocument/codeAction - (44)' in 1ms.
No result returned.
Error: {
  "code": -32603,
  "message": "Internal error.",
  "data": "java.lang.RuntimeException: java.lang.reflect.InvocationTargetException\n\tat org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:67)\n\tat org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request(GenericEndpoint.java:120)\n\tat org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest(RemoteEndpoint.java:261)\n\tat org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:190)\n\tat org.eclipse.lsp4mp.ls.commons.ParentProcessWatcher.lambda$apply$0(ParentProcessWatcher.java:148)\n\tat org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)\n\tat org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)\n\tat org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)\n\tat java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)\n\tat java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)\n\tat java.base/java.lang.Thread.run(Thread.java:1583)\nCaused by: java.lang.reflect.InvocationTargetException\n\tat java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:115)\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:580)\n\tat org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)\n\t... 12 more\nCaused by: java.lang.NullPointerException: Cannot invoke \"org.eclipse.lsp4mp.ls.java.JavaTextDocuments$JavaTextDocument.executeIfInMicroProfileProject(java.util.function.BiFunction, Object)\" because \"document\" is null\n\tat org.eclipse.lsp4mp.ls.java.JavaFileTextDocumentService.codeAction(JavaFileTextDocumentService.java:225)\n\tat org.eclipse.lsp4mp.ls.MicroProfileTextDocumentService.codeAction(MicroProfileTextDocumentService.java:220)\n\tat java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)\n\t... 14 more\n"
}

This error is very strange because it should send:

[Trace - 19:32:17] Received request 'microprofile/java/codeAction - (10)'

but it seems it crashes?

Is there any chance that you share your project?

@mfortunat
Copy link
Author

mfortunat commented Sep 11, 2024

No, sorry.
It's not a personal project.
What I can tell you is that is a multimodule maven project based on Quarkus 3.10.0, with Apache Camel, and with Kafka and MongoDB Camel components.

I don't remember all of these issues with LSF4IJ 0.4.0

@angelozerr angelozerr added the bug Something isn't working label Sep 12, 2024
@angelozerr
Copy link
Contributor

It is very hard for me to understand the problem since I cannot reproduce it -(

@angelozerr
Copy link
Contributor

If you can find another relelvant logs, please attach it.

@angelozerr
Copy link
Contributor

angelozerr commented Sep 12, 2024

After investigating again your LSP trace, the error comes from the MicroProfile LS at https://github.com/eclipse/lsp4mp/blob/46bdf69f725349371c401066f85f2034a6fbec2f/microprofile.ls/org.eclipse.lsp4mp.ls/src/main/java/org/eclipse/lsp4mp/ls/java/JavaFileTextDocumentService.java#L225

It seems document which is the opened Java file is null? I can fix that on MP LS side, but I don't understand how to you can have this usecase.

According your LSP traces you close several files and after that you reopen them. I wonder if you are using a menu contextual or another thing to reopen them in same time?

@mfortunat
Copy link
Author

mfortunat commented Sep 12, 2024

I wasn't opening or closing documents at all.
I had a set of open Java files, one or two properties files and a pom file.
Simply moving the cursor generated a new error at each keypress or mouse click.

The very long log file I attached was produced in just a bunch of seconds.

@angelozerr
Copy link
Contributor

Before having your issue, you have closed serveral files and open theJava file which causes the problemand after that you were in a bad state. I don't know why. I need to understand how to reproduce this usecase.

Can you reproduce everytime?

@mfortunat
Copy link
Author

mfortunat commented Sep 12, 2024

No, I generally close IJ when I end working with it and restart the following day with the same open files.
When I close/open files in general is 2 or 3 of them, never 20 or 30 or more.

Yesterday I rerun IJ several times, and every time it was producing the errors.
It's about 3 hrs it is up today, and I haven't had a single issue (so far and keeping fingers crossed).

BTW, I haven't installed/upgraded anything at OS level

@angelozerr
Copy link
Contributor

@mfortunat
Copy link
Author

Hi @angelozerr,

Thanks for the info.
It is working pretty well right now (I also upgraded IJ to the latest version) so I prefer to stay with the official stable version.

Thank you anyway!

@angelozerr
Copy link
Contributor

Hi @angelozerr,

Thanks for the info.
It is working pretty well right now (I also upgraded IJ to the latest version) so I prefer to stay with the official stable version.

Thank you anyway!

Ok I understand but I wanted to have some feedback from you because we plan to do releases next week and LSP4IJ should be improved by starting l1nguage servers when all indexing from all projects are finished.

It should (I hope and according my tests, there are a big improvement) fix performance problem and a lot of awfull errors.

@mfortunat
Copy link
Author

Hi @angelozerr, I'm very busy this week and the next due to Thanksgiving, Black Friday, and Cyber Monday.
I need my IJ to be fully functional; I have no time for installation or uninstallation, but I will see what I can do starting from December.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants