-
Notifications
You must be signed in to change notification settings - Fork 443
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
Added restart java language server command #2586
Added restart java language server command #2586
Conversation
It seems the standard server won't start back up when the server mode is |
What happens if in the "Hybrid" case, you use |
d5c99f6
to
4619154
Compare
Originally |
4619154
to
0d1aa4c
Compare
Ah I see, because StandardLanguageClient.stop() is a wrapper for the LanguageClient.stop() |
48f9e66
to
5d41d75
Compare
src/extension.ts
Outdated
switch (getJavaServerMode()) { | ||
case (ServerMode.STANDARD): | ||
// Standard server restart | ||
await standardClient.restart(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using the wrapper start(), stop(), I instead created a restart for both the standardClient and syntaxClient. This way, the languageClient won't be set to null and the ClientStatus won't change.
65ee0a9
to
56369b0
Compare
56369b0
to
a174d98
Compare
@testforstephen , you mentioned there's already an issue, or PR for this that's incoming ? I wasn't able to find any issue on the vscode-java-debug end. |
@rgrunber I tried this PR and Java debugger works fine after a language server restart. The reason is that the current restart implementation does not trigger a server mode change event and has no effect on the debugger. Previously we saw some side effects when restarting because that implementation would destroy the languageClient and recreate a new one, which would cause the Java extension to resend the server mode change event. However, I found another issue that the status icon is always spinning after language server restart. |
I think I saw this as well initially. Our own wrappers destroy the entire client, but we don't need to do that, so I believe @AlexXuChen just made a separate method that just calls the necessary API on the Yes, I saw the spinning build status provider as well, and hopefully it can be fixed. As the startup process receives a lot of notifications and state changes, perhaps something isn't set correctly or expecting to go through an earlier phase again. @testforstephen , if there's no PR planned (or other draft) on your end to address this, I think Alex should continue improving this, as it would be nice to have such a restart capability. |
6bc6704
to
cf9f568
Compare
I just tried this PR with vscode-microprofile, which provides a eclipse.jdt.ls extension and a language server that communicates with the eclipse.jdt.ls extension using language server commands. Restarting works very well; as soon as the server restarts, all the microprofile features start working again. The only issue I ran into while doing this is that the microprofile language server sends sends error notifications while eclipse.jdt.ls is down. This makes sense, since the microprofile language server is trying to make requests to eclipse.jdt.ls while it's not running. However, it might confuse the end user, since they might think something is wrong. It would be nice to prevent these errors from appearing, perhaps with an API to detect if the server is restarting, but I think that could wait to a future PR. |
b19a48f
to
0cb41b7
Compare
0cb41b7
to
756fbfb
Compare
The only other issue I see is that in syntax client mode ( Update : This appears to be #2366
This could probably be done with |
756fbfb
to
6eabc50
Compare
In the process of trying to make the progress notification disappear once the server is responding again (as opposed to once the restart command has finished being issued), I've discovered that once the language server is restarted, it fails to receive notifications on any of the Although this is a deal breaker, it's actually microsoft/vscode-languageserver-node#770, which was fixed in 8.0. So we now depend on #2474 in order to merge this change. Hopefully we'll be able to do that pretty soon. |
2a860a6
to
9de9f7e
Compare
9de9f7e
to
6bcaadb
Compare
As a side note, I run into the following problem while in debug mode sometimes:
The problem is solved with the timeout set to 2000 instead of 1000 here: |
In the previous iteration of this PR, we had it set at 2000 (I suspect I saw issues with 1000). However now it's handled by the library so we don't really have control. It's mainly an annoying problem for developers because in production those debug ports aren't open (so no cases of LS shutdown still bound to 1044 while new one starting attempts to bind to 1044) though. Worst case, we could just do what we did before. Copy the |
This works really well for me with the eclipse.jdt.ls modification to the Shutdown job. I've tried restarting with various launch modes. I noticed that if no server is running (eg. invisible project with no files opened, or empty workspace), one can still restart the language server (though it never started once to begin with). It doesn't appear harmful. Still seems to succeed although maybe we shouldn't allow this to happen. Have a look at the |
6bcaadb
to
f0a5fe2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would just add your info as a Co-authored-by:
in the commit body (at the bottom) and I think we can merge.
- Show progress for restarting the language server Signed-off-by: AlexXuChen <[email protected]> Co-authored-by: Roland Grunberg <[email protected]> Co-authored-by: Jessica He <[email protected]>
f0a5fe2
to
ae82808
Compare
Added Restart Java Language Server command,
java.language.server.restart
.Signed-off-by: Alexander Chen [email protected]