OpenLiberty / liberty-tools-intellij

IntelliJ IDEA extension for Liberty
https://plugins.jetbrains.com/plugin/14856-open-liberty-tools
Eclipse Public License 2.0
14 stars 26 forks source link

Diagnostics are not always published when a file containing an error is opened. #648

Open mrglavas opened 9 months ago

mrglavas commented 9 months ago

I have observed this issue with Liberty Tools for IntelliJ (useLSP4IJ1201 branch) and Quarkus Tools v1.30.1. Occasionally when I open a file containing an error, no diagnostics are published. This doesn't seem to happen often but I've been able to reproduce it. To reproduce this, I open and close one file (specifically the ServiceLiveHealthCheck class with the @Liveness annotation removed from a MicroProfile starter project) repeatedly, allowing the MicroProfile language server to shutdown completely before opening the file again. Eventually when I open the file, no diagnostics will be displayed. I'm guessing there must be a timing issue and something with the language server/client isn't initialized around the time diagnostics would have been collected and published.

Screenshot of IntelliJ with the Liberty Tools plug-in installed: image

Screenshot of IntelliJ with the Quarkus Tools plug-in installed: image

mrglavas commented 9 months ago

Opened and linked https://github.com/redhat-developer/lsp4ij/issues/139 to this issue.

turkeylurkey commented 9 months ago

In the case of the diagnostic not appearing the diagnostic participant is not called. Also no microprofile/java/diagnostics message is sent from the language server.

turkeylurkey commented 9 months ago

On VS Code the two projectLabels requests have complete responses:

image

On IntelliJ one of them is blank and the other is populated:

image image
turkeylurkey commented 9 months ago

"No result returned" may mean the message request was cancelled.

angelozerr commented 9 months ago

"No result returned" may mean the message request was cancelled.

Do you see in the LSP console a cancel trace like:

[Trace - 08:53:15] Sending notification '$/cancelRequest'
Params: {
  "id": "3"
}
turkeylurkey commented 9 months ago

No, the traces look just like the IntelliJ traces (Liberty, Quarkus) seen in the original message above. But in the console log there is image

angelozerr commented 9 months ago

Ok thanks for your information. I will try to investigate the problem when I will have some time (I'm busy for the moment with https://github.com/redhat-developer/lsp4ij/pull/137)

TrevCraw commented 9 months ago

@turkeylurkey to attempt a temporary solution to mitigate this problem. When releasing, we should document this problem on the known problems wiki page and provide a link in the release notes.

angelozerr commented 9 months ago

It seems that you have fixed the issue, but I'm not sure that it is the correct fix.

If you wait for the timout that you have defined and you retry to open it, I think you will have the same problem.

I suspect that it is a problem with a cancel of projectLabels, but I need to find time to investgate the problem.

mrglavas commented 9 months ago

I think Paul was just trying to reduce the probability that the user could hit this issue while this is still being investigated for the correct fix.

TrevCraw commented 9 months ago

Re-opening since the fix that went in is intended to mitigate the problem, not fully resolve it.

anusreelakshmi934 commented 5 months ago

I have tested it using Latest LSP4IJ ( 0.0.2 ). When I open a file containing an error, diagnostics are published. I tried opening and closing ServiceLiveHealthCheck class with the @Liveness annotation removed repeatedly. When I open the file, diagnostics were displayed correctly.

https://github.com/OpenLiberty/liberty-tools-intellij/assets/141303561/946e2f7e-18ec-436a-8c75-5b88f7bf99ed

mrglavas commented 5 months ago

@anusreelakshmi934 With the temporary solution that @turkeylurkey introduced it became harder to reproduce this issue. I believe he changed the timeout on shutting down the language server to 10 hours. We suspected the issue was related to the language server start-up. If you want to verify if the underlying problem is still there, you could undo the timeout change: https://github.com/OpenLiberty/liberty-tools-intellij/pull/662 in a local build and then check again.

anusreelakshmi934 commented 4 months ago

I reverted the timeout code and checked for the diagnostics. I was able to get the diagnostics.

https://github.com/OpenLiberty/liberty-tools-intellij/assets/141303561/17d97f05-eb6b-43f6-b3da-43a782a8c330

turkeylurkey commented 4 months ago

I was opening and closing all the files and I ran across the situation below, the diagnostics did not appear.

image

It was not easy to reproduce. It took about 30 repetitions of opening some files, closing them all, restarting the Jakarta and MP language servers, opening and closing more files and several times restarting the IDE.

It looks like it can happen but rarely.

anusreelakshmi934 commented 4 months ago

After further testing I was able to reproduce the error of not getting the diagnostic. In InvalidWebFilter (src/test/resources/projects/maven/jakarta-sample/src/main/java/io/openliberty/sample/jakarta/servlet/InvalidWebFilter.java) file, diagnostics were not dispalyed upon opening and closing the file repeatedly. Again if i close this file and open it back again i am getting the diagnostic.

image

In some cases i am getting the diagnostic but not the quickfixes. image

Attaching Trace [Trace - 20:05:36] Sending request 'textDocument/hover - (294)'. Params: { "textDocument": { "uri": "file:///Users/anusreelakshmi/Documents/DevEx/liberty-tools-intellij/src/test/resources/projects/maven/jakarta-sample/src/main/java/io/openliberty/sample/jakarta/servlet/InvalidWebFilter.java" }, "position": { "line": 5, "character": 9 } } [Trace - 20:05:36] Received response 'textDocument/hover - (294)' in 7ms. No result returned. [Trace - 20:05:39] Sending notification 'textDocument/didClose' Params: { "textDocument": { "uri": "file:///Users/anusreelakshmi/Documents/DevEx/liberty-tools-intellij/src/test/resources/projects/maven/jakarta-sample/src/main/java/io/openliberty/sample/jakarta/servlet/InvalidWebFilter.java" } } [Trace - 20:05:39] Received notification 'textDocument/publishDiagnostics' Params: { "uri": "file:///Users/anusreelakshmi/Documents/DevEx/liberty-tools-intellij/src/test/resources/projects/maven/jakarta-sample/src/main/java/io/openliberty/sample/jakarta/servlet/InvalidWebFilter.java", "diagnostics": [] } [Trace - 20:05:41] Sending notification 'textDocument/didOpen' Params: { "textDocument": { "uri": "file:///Users/anusreelakshmi/Documents/DevEx/liberty-tools-intellij/src/test/resources/projects/maven/jakarta-sample/src/main/java/io/openliberty/sample/jakarta/servlet/InvalidWebFilter.java", "languageId": "java", "version": 1, "text": "package io.openliberty.sample.jakarta.servlet;\n\nimport jakarta.servlet.Filter;\nimport jakarta.servlet.annotation.WebFilter;\n\n@WebFilter()\npublic abstract class InvalidWebFilter implements Filter {\n\n}\n\n\n" } } [Trace - 20:05:41] Received request 'jakarta/java/fileInfo - (436)' Params: { "uri": "file:///Users/anusreelakshmi/Documents/DevEx/liberty-tools-intellij/src/test/resources/projects/maven/jakarta-sample/src/main/java/io/openliberty/sample/jakarta/servlet/InvalidWebFilter.java" } [Trace - 20:05:41] Received request 'jakarta/java/projectLabels - (437)' Params: { "uri": "file:///Users/anusreelakshmi/Documents/DevEx/liberty-tools-intellij/src/test/resources/projects/maven/jakarta-sample/src/main/java/io/openliberty/sample/jakarta/servlet/InvalidWebFilter.java", "types": [ "jakarta.ws.rs.GET", "jakarta.ws.rs.POST", "jakarta.ws.rs.PUT", "jakarta.ws.rs.DELETE", "jakarta.ws.rs.HEAD", "jakarta.servlet.GenericServlet", "jakarta.servlet.http.HttpServlet", "jakarta.servlet.Filter", "jakarta.persistence.PersistenceContextType", "jakarta.persistence.Entity", "jakarta.validation.constraints.Email", "jakarta.transaction.UserTransaction", "jakarta.transaction.Transactional" ] } [Trace - 20:05:41] Sending response 'jakarta/java/fileInfo - (436)'. Processing request took 3ms Result: { "packageName": "io.openliberty.sample.jakarta.servlet" } [Trace - 20:05:41] Sending response 'jakarta/java/projectLabels - (437)'. Processing request took 12ms Result: { "uri": "jakarta-servlet", "name": "jakarta-servlet", "labels": [ "jakarta", "microprofile", "maven", "jakarta.ws.rs.GET", "jakarta.ws.rs.POST", "jakarta.ws.rs.PUT", "jakarta.ws.rs.DELETE", "jakarta.ws.rs.HEAD", "jakarta.servlet.GenericServlet", "jakarta.servlet.http.HttpServlet", "jakarta.servlet.Filter", "jakarta.persistence.PersistenceContextType", "jakarta.persistence.Entity", "jakarta.validation.constraints.Email", "jakarta.transaction.UserTransaction", "jakarta.transaction.Transactional" ] } [Trace - 20:05:41] Received request 'jakarta/java/diagnostics - (438)' Params: { "uris": [ "file:///Users/anusreelakshmi/Documents/DevEx/liberty-tools-intellij/src/test/resources/projects/maven/jakarta-sample/src/main/java/io/openliberty/sample/jakarta/servlet/InvalidWebFilter.java" ], "documentFormat": 2, "settings": {} } [Trace - 20:05:41] Sending response 'jakarta/java/diagnostics - (438)'. Processing request took 26ms Result: [ { "uri": "file:///Users/anusreelakshmi/Documents/DevEx/liberty-tools-intellij/src/test/resources/projects/maven/jakarta-sample/src/main/java/io/openliberty/sample/jakarta/servlet/InvalidWebFilter.java", "diagnostics": [ { "range": { "start": { "line": 5, "character": 0 }, "end": { "line": 5, "character": 12 } }, "severity": 1, "code": "CompleteWebFilterAttributes", "source": "jakarta-servlet", "message": "The annotation @WebFilter must define the attribute \u0027urlPatterns\u0027, \u0027servletNames\u0027 or \u0027value\u0027." } ] } ] [Trace - 20:05:41] Received notification 'textDocument/publishDiagnostics' Params: { "uri": "file:///Users/anusreelakshmi/Documents/DevEx/liberty-tools-intellij/src/test/resources/projects/maven/jakarta-sample/src/main/java/io/openliberty/sample/jakarta/servlet/InvalidWebFilter.java", "diagnostics": [ { "range": { "start": { "line": 5, "character": 0 }, "end": { "line": 5, "character": 12 } }, "severity": 1, "code": "CompleteWebFilterAttributes", "source": "jakarta-servlet", "message": "The annotation @WebFilter must define the attribute \u0027urlPatterns\u0027, \u0027servletNames\u0027 or \u0027value\u0027." } ] } [Trace - 20:05:42] Sending request 'textDocument/codeAction - (295)'. Params: { "textDocument": { "uri": "file:///Users/anusreelakshmi/Documents/DevEx/liberty-tools-intellij/src/test/resources/projects/maven/jakarta-sample/src/main/java/io/openliberty/sample/jakarta/servlet/InvalidWebFilter.java" }, "range": { "start": { "line": 6, "character": 22 }, "end": { "line": 6, "character": 22 } }, "context": { "diagnostics": [], "triggerKind": 2 } } [Trace - 20:05:42] Received request 'jakarta/java/codeAction - (439)' Params: { "resourceOperationSupported": false, "commandConfigurationUpdateSupported": false, "resolveSupported": false, "textDocument": { "uri": "file:///Users/anusreelakshmi/Documents/DevEx/liberty-tools-intellij/src/test/resources/projects/maven/jakarta-sample/src/main/java/io/openliberty/sample/jakarta/servlet/InvalidWebFilter.java" }, "range": { "start": { "line": 6, "character": 22 }, "end": { "line": 6, "character": 22 } }, "context": { "diagnostics": [], "triggerKind": 2 } } [Trace - 20:05:42] Sending response 'jakarta/java/codeAction - (439)'. Processing request took 4ms Result: [] [Trace - 20:05:42] Received response 'textDocument/codeAction - (295)' in 10ms. Result: [] [Trace - 20:07:49] Sending request 'textDocument/hover - (296)'. Params: { "textDocument": { "uri": "file:///Users/anusreelakshmi/Documents/DevEx/liberty-tools-intellij/src/test/resources/projects/maven/jakarta-sample/src/main/java/io/openliberty/sample/jakarta/servlet/InvalidWebFilter.java" }, "position": { "line": 5, "character": 7 } } [Trace - 20:07:49] Received response 'textDocument/hover - (296)' in 15ms. No result returned. [Trace - 20:09:52] Sending request 'textDocument/codeAction - (297)'. Params: { "textDocument": { "uri": "file:///Users/anusreelakshmi/Documents/DevEx/liberty-tools-intellij/src/test/resources/projects/maven/jakarta-sample/src/main/java/io/openliberty/sample/jakarta/servlet/InvalidWebFilter.java" }, "range": { "start": { "line": 11, "character": 0 }, "end": { "line": 11, "character": 0 } }, "context": { "diagnostics": [], "triggerKind": 2 } } [Trace - 20:09:52] Received request 'jakarta/java/codeAction - (440)' Params: { "resourceOperationSupported": false, "commandConfigurationUpdateSupported": false, "resolveSupported": false, "textDocument": { "uri": "file:///Users/anusreelakshmi/Documents/DevEx/liberty-tools-intellij/src/test/resources/projects/maven/jakarta-sample/src/main/java/io/openliberty/sample/jakarta/servlet/InvalidWebFilter.java" }, "range": { "start": { "line": 11, "character": 0 }, "end": { "line": 11, "character": 0 } }, "context": { "diagnostics": [], "triggerKind": 2 } } [Trace - 20:09:52] Sending response 'jakarta/java/codeAction - (440)'. Processing request took 10ms Result: [] [Trace - 20:09:52] Received response 'textDocument/codeAction - (297)' in 29ms. Result: [] [Trace - 20:10:00] Sending request 'textDocument/hover - (298)'. Params: { "textDocument": { "uri": "file:///Users/anusreelakshmi/Documents/DevEx/liberty-tools-intellij/src/test/resources/projects/maven/jakarta-sample/src/main/java/io/openliberty/sample/jakarta/servlet/InvalidWebFilter.java" }, "position": { "line": 5, "character": 5 } } [Trace - 20:10:00] Received response 'textDocument/hover - (298)' in 1ms. No result returned.
vaisakhkannan commented 2 months ago

When I repeatedly opened and closed a java file, I noticed that the LSP4MP diagnostics were missing in some cases. However, if I closed and reopened the file again, the diagnostics would appear.

version of LTI - 24.0.9 - candidate driver version of LSP4IJ - 0.4.1-20240906-013124 version of IntelliJ - 2024.1.6 file - Java file version of LSP4MP - 0.12.0

https://github.com/user-attachments/assets/653f0db6-6825-49d2-ade8-4546892ffff6

turkeylurkey commented 2 months ago

I see this about 10% of the time in testing 24.0.9 snapshot using the process documented.

anusreelakshmi934 commented 2 months ago

While testing with LSP4IJ version 0.5.0, I opened a file containing an error that is @Liveness removed, diagnostics were published. However, when I opened and closed the file repeatedly, the diagnostics were sometimes not published.