Open turkeylurkey opened 7 months ago
I found Intellij extension getting stuck while testing the below test
test --tests "io.openliberty.tools.intellij.it.GradleSingleModJakartaLSTest.testJakartaQuickFixInJavaPart"
( which is part of the above failure)
I did force quit the extension first, then, I opened it again and found the below exception.
Freeze for 40 seconds
IDE KILLED! Sampled time: 31800ms, sampling rate: 100ms, GC time: 284ms (0%), Class loading: 0%
The stack is from the thread that was blocking EDT
com.intellij.diagnostic.Freeze
at java.base@17.0.10/jdk.internal.misc.Unsafe.park(Native Method)
at java.base@17.0.10/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:252)
at java.base@17.0.10/java.util.concurrent.CompletableFuture$Signaller.block(CompletableFuture.java:1866)
at java.base@17.0.10/java.util.concurrent.ForkJoinPool.compensatedBlock(ForkJoinPool.java:3451)
at java.base@17.0.10/java.util.concurrent.ForkJoinPool.managedBlock(ForkJoinPool.java:3434)
at java.base@17.0.10/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1939)
at java.base@17.0.10/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2095)
at org.microshed.lsp4ij.CompletableFutures.waitUntilDone(CompletableFutures.java:78)
at org.microshed.lsp4ij.operations.codeactions.LSPLazyCodeActions.getOrLoadCodeActions(LSPLazyCodeActions.java:131)
at org.microshed.lsp4ij.operations.codeactions.LSPLazyCodeActions.getCodeActionAt(LSPLazyCodeActions.java:90)
at org.microshed.lsp4ij.operations.codeactions.LSPLazyCodeActionIntentionAction.loadCodeActionIfNeeded(LSPLazyCodeActionIntentionAction.java:148)
at org.microshed.lsp4ij.operations.codeactions.LSPLazyCodeActionIntentionAction.isAvailable(LSPLazyCodeActionIntentionAction.java:72)
at com.intellij.codeInsight.intention.impl.ShowIntentionActionsHandler.availableFor(ShowIntentionActionsHandler.java:218)
at com.intellij.codeInsight.daemon.impl.ShowIntentionsPass.lambda$addAvailableFixesForGroups$2(ShowIntentionsPass.java:148)
at com.intellij.codeInsight.daemon.impl.ShowIntentionsPass$$Lambda$5662/0x0000000802537548.apply(Unknown Source)
at com.intellij.codeInsight.daemon.impl.HighlightInfo.find(HighlightInfo.java:124)
at com.intellij.codeInsight.daemon.impl.HighlightInfo.findRegisteredQuickFix(HighlightInfo.java:109)
at com.intellij.codeInsight.daemon.impl.ShowIntentionsPass.addAvailableFixesForGroups(ShowIntentionsPass.java:114)
at com.intellij.codeInsight.daemon.impl.ShowIntentionsPass.getActionsToShow(ShowIntentionsPass.java:324)
at com.intellij.codeInsight.daemon.impl.ShowIntentionsPass.doCollectInformation(ShowIntentionsPass.java:255)
at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:55)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$1(PassExecutorService.java:406)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass$$Lambda$5174/0x0000000802378250.consume(Unknown Source)
at com.intellij.platform.diagnostic.telemetry.helpers.TraceKt.runWithSpanIgnoreThrows(trace.kt:76)
at com.intellij.platform.diagnostic.telemetry.helpers.TraceUtil.runWithSpanThrows(TraceUtil.java:34)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$2(PassExecutorService.java:401)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass$$Lambda$5167/0x0000000802371b90.run(Unknown Source)
at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1075)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$3(PassExecutorService.java:392)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass$$Lambda$5163/0x0000000802371250.run(Unknown Source)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$12(CoreProgressManager.java:610)
at com.intellij.openapi.progress.impl.CoreProgressManager$$Lambda$883/0x0000000800912460.compute(Unknown Source)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:685)
at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:641)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:609)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:78)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.doRun(PassExecutorService.java:391)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$run$0(PassExecutorService.java:367)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass$$Lambda$5160/0x000000080236fab0.run(Unknown Source)
at com.intellij.openapi.application.impl.ReadMostlyRWLock.executeByImpatientReader(ReadMostlyRWLock.java:200)
at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:184)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:365)
at com.intellij.concurrency.JobLauncherImpl$VoidForkJoinTask$1.exec(JobLauncherImpl.java:187)
at java.base@17.0.10/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
at java.base@17.0.10/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
at java.base@17.0.10/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
at java.base@17.0.10/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
at java.base@17.0.10/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
Did you see this issue @turkeylurkey before?
I can see that the exception is coming from org.microshed.lsp4ij
.
This is interesting but it might be expected for lsp4ij to be waiting for a response. We could investigate whether the language server crashed for some reason and hence did not respond. Or maybe the language server is just slow. Also I wonder if we are requesting code actions when it looks like a Java error, it does not look like one of our language servers has detected a diagnostic.
The reason our language servers have not detected diagnostics is because IntelliJ got stuck before writing "{", as shown in the screenshot above. @mrglavas Have you seen this issue before?
@vaisakhkannan No, I've never encountered this before. If this is exclusively happening on MacOS that might explain why I haven't seen it. I run Windows on my workstation.
Regarding the stack trace you posted, I thought the CompletableFutures.waitUntilDone()
method was written such that the thread periodically wakes up and checks if the action has been cancelled. I've never seen this working in action but I assumed there was some way to cancel and break out of the otherwise infinite wait without force quitting IntelliJ.
I found Intellij extension getting stuck while testing the below test
@vaisakhkannan have you the problem with only the JUnit or too while editing the Java file?
Regarding the stack trace you posted, I thought the CompletableFutures.waitUntilDone() method was written such that the thread periodically wakes up and checks if the action has been cancelled. I've never seen this working in action but I assumed there was some way to cancel and break out of the otherwise infinite wait without force quitting IntelliJ.
Indeed the main idea is to check unitl 25 ms:
This code avoid using timeout but if those two conditions are not matched, they will an infinite loop. I would like to really avoid using a timeout which breaks the LSP requests, but @vaisakhkannan if you have a problem while editing a file,it is a very very annoying problem.
@vaisakhkannan could you tell me please if you have encountered the problem of freeze by editing a file or it is just a matter with test.
I need to improve this wait until to prévent from infinite loop
Hi @vaisakhkannan , @mrglavas and I were discussing this issue and we had a few thoughts:
You need to follow those rules:
I have tried to emulate the slow computing of code action with a Thread.sleep(10000) and I type a character in the editor, I have noticed that:
As LSP4IJ uses ReadAction.nonBlocking to compute anything on IJ side (to collect information from PsiJavaFile), I suggest that you read https://plugins.jetbrains.com/docs/intellij/general-threading-rules.html#read-action-cancellability
But I need to implement https://github.com/eclipse/lsp4mp/issues/442 to have better cancellability
@angelozerr, I have encountered the issue of freezing only during UI testing and have not found any problems when editing a file.
@angelozerr, I have encountered the issue of freezing only during UI testing and have not found any problems when editing a file.
It is a great news!
You need to follow those rules:
* computing code action list should be very fast, it means that you need to support resolve code action. The call of codeAction should return the list od code action without TextEdit which can be very slow. Do you support resolve code action?
Our LSP4Jakarta client has everything in place to support resolving code actions. The client API even now has the resolveCodeAction() method to align with LSP4MP but I understand that the language server itself hasn't yet enabled this path and so it's still eagerly computing the text edits. Both MicroProfile and Jakarta share the same component: https://github.com/OpenLiberty/liberty-tools-intellij/blob/main/src/main/java/io/openliberty/tools/intellij/lsp4mp4ij/psi/internal/core/java/codeaction/CodeActionHandler.java. The code paths executed should be identical once the Jakarta language server supports resolve code action.
The code paths executed should be identical once the Jakarta language server supports resolve code action.
Once jakarta ls will support resolve code action I think it should fix your problem of this issue.
But as I said, the jakarta ls should support the cancellation of the future java/*/codeAction to improve again the performance when code action is cancelled on lsp client side.
You will have this usecase if you align your lsp4ij with our lsp4ij. I have managed refactor code action where code action appears even if there are not an error. In this case code action is called one each cursor caret changes.
The code paths executed should be identical once the Jakarta language server supports resolve code action.
Once jakarta ls will support resolve code action I think it should fix your problem of this issue.
But as I said, the jakarta ls should support the cancellation of the future java/*/codeAction to improve again the performance when code action is cancelled on lsp client side.
I was just about to comment on this. This feels like common code that could be shared between LSP4MP and LSP4Jakarta. I know Andy/Ed have been exploring commonality between the language servers and I think this could fit well in that layer. I guess in the short term they would copy your solution in LSP4MP into LSP4Jakarta.
You will have this usecase if you align your lsp4ij with our lsp4ij. I have managed refactor code action where code action appears even if there are not an error. In this case code action is called one each cursor caret changes.
We're making progress in that direction. It's been challenging for us to find a stable baseline which is why we're still taking snapshots and applying targeted fixes to them to resolve issues with upgrading to the new level. The current one is based on LSP4iJ from April 1st so hopefully not that far off of what's currently there. We do want to get to a point where we can just pull directly from the official project and just use what's being released. I've been meaning to ask about the stability of the API/component. Ideally upgrading to a new version of LSP4iJ (or any dependency for that matter) should be as simple as updating the version number and everything still works without requiring other code changes. In practice, it hasn't been that simple yet.
We plan to do a release soon with @fbricon when I will finish the rename symbol support.
I hope API will be stable but I think we need again some refactoring.
Once release will be done I will promote lsp4ij to several community like go rust scala clojure since now it is super easy to integrate any language server which supports stdio without developping an ij plugin https://github.com/redhat-developer/lsp4ij/blob/main/docs%2FUserDefinedLanguageServer.md
Thanks, @angelozerr. Do you have an outlook for the refactoring work that may still be needed for the API?
@yeekangc we plan to do a release soon and I hope I will do less refactoring, but as I'm not the author of the origin code it is hard to say that I will stop refactoring.
I tested it with the latest pull of lsp4ij. Today, I completed the entire testing process and noticed some issues: not getting hover descriptions in bootstrap.properties and server.env files
( during UI Testing also), so those tests failed. Additionally, I haven't seen the 'java.net.SocketTimeoutException: Read timed out' failure when I tested it locally.
java.net.SocketTimeoutException: Read timed out
this was the main reason behind mac os build failure.
So I hoping it that , latest pull of lsp4ij will resolve mac os build failure that we are getting now.
I tested it with the latest pull of lsp4ij. Today, I completed the entire testing process and noticed some issues: not getting hover descriptions in
bootstrap.properties and server.env files
( during UI Testing also), so those tests failed. Additionally, I haven't seen the 'java.net.SocketTimeoutException: Read timed out' failure when I tested it locally.java.net.SocketTimeoutException: Read timed out
this was the main reason behind mac os build failure. So I hoping it that , latest pull of lsp4ij will resolve mac os build failure that we are getting now.
@vaisakhkannan We are aware of the issues (see https://github.com/OpenLiberty/liberty-tools-intellij/issues/717) with hover text not being displayed (after the LSP4iJ upgrade) for property names in bootstrap.properties
and server.env
and have been investigating. We are still trying to determine the root cause. Five tests in total are failing on Linux.
Once we use the latest LSP4IJ
, ensure to check this issue and test whether all the tests are passing on Mac
.
This looks like the IntelliJ UI hanged when it did not display {
after it had been typed. I had this problem using a copy of lsp4ij to which I had added logging.
Once this happens we probably cannot recover and reestablish communication so it would be best to let it fail and retry in a new test run.
Perhaps exit JUnit with a code we can check for and then rerun if we detect this code. Alternatively search the log of the test run for this exception and rerun if necessary.
Searching the log was successful and then the return code of 23 is used:
Process 'Gradle Test Executor 1' finished with non-zero exit value 23
Still need to shutdown IntelliJ under test to allow restart.
The UI robot is trying to type characters into the editor but the editor process is not confirming the characters.
In https://github.com/OpenLiberty/liberty-tools-intellij/actions/runs/8436692171/job/23104688837