-
Notifications
You must be signed in to change notification settings - Fork 324
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
how to reliably catch rejected LanguageClient onReady promise? #825
Comments
@lovettchris which version are you on? 7.0.x. This version had quite some unhandled promise code (which resulted in this). I fixed this and the new 8.0.x version will handle this a lot better, but is breaking in terms of return values (more methods return a promise and not directly the value). I will post a next version of the library this week after VS Code has shipped stable. I would like to ask you to give it a try and let me know if this improved. |
I am using "vscode-languageclient": "^7.0.0". I will try upgrading when your new version comes out, thanks. |
I was on 7.0.0, so I moved to "vscode-languageclient": "^8.0.0-next.2", and the problem seems to be fixed. My try/catch works reliably now when my server cannot be started. But an interesting thing happens now when my server does start properly, sometimes I get this console output later on when everything is up and running. Perhaps you delayed reporting of the actual rejected promise? How do I find out what promise this is? I guess this is more of a typescript debugging question... How does one find out what (if any) operation my extension initiated that resulted in these stack traces? I suspect it is the StreamMessageReader(serverProcess.stdout) and StreamMessageWriter(serverProcess.stdin) of LanguageClient.createMessageTransports... and I can repro this more easily when I "restart" my client, calling client.stop() on the old one and creating a new LanguageClient to call start and onReady. My server is up and running, and everything seems to be working fine, so perhaps this is just a spurious error from when I closed the old client?
|
That looks strange. I do the same in my language server (stop and then a start) and didn't see that. Do you have any easy steps to reproduce? |
I reverted my upgrade to 8.0.0 because some other things stopped working, I probably need to adjust to some LSP api changes or something. But if you want to repro the issue you can get these bits and run them in the vscode debugger with F5, and open a folder containing a file named "Hello.lean" where the file contains this text: import Leanpkg
#eval Leanpkg.leanVersionString First you will see this prompt: Click "Install Lean" and you should see some options, press "1" and ENTER, and "ENTER" a couple more times and you should see the Lean server come up with a message "Lean (version 4.0.0-nightly-2021-10-07, commit 7f660af4c6d3, Release)". Cool, so boot strapping worked, but now run: Ctrl+sHIFT+P , "Lean 4: Select Interpreter", leave the string "lean" and hit ENTER. and you will see the client has stopped, starting, running, but then after that this error appears:
PS: windows defender started a false positive attack on our github zip file today, (which I'm looking into) but you can override the quarantine using an admin command prompt if you run
|
Oh, man, never mind, I did the upgrade to 8.0.0 properly this time and added some missing 'void' to some client.sendNotification calls, as per the release notes, and now this error is gone! So it looks like 8.0.0 is the fix, can you resolve this open issue after you post the official 8.0.0 release? |
Thanks for getting back. I will close it and label for 3.17 which is the LSP release number |
@dbaeumer, any idea why this version of the LSP requires such a recent version of vscode (only 13 days old)? my customers are complaining my extension wont work on their version of vscode...? |
@lovettchris the extension has support for type hierarchies which are available since that latest version of VS Code. That is why it prereqs 1.61.0 |
See leanclient.ts
I'm trying to catch the exception thrown if my client fails to start using try catch, like this:
But it only works sometimes. If I do a clean "Developer: Reload Window" on a project that loads my extension then it fails to work and I see this output in my console log:
The vscode instance I'm debuggin has this expected output window:
If I run this same code to start my LanguageClient from my own command the try/catch works fine and I get this console log output:
This is the better expected output and you can see vscode tries to launch my client 5 times as expected and so on. I tried looking at all exceptions thrown but didn't see anything obviously wrong in my code. I also tried setting all breakpoints in my code to see if it is something else responding to some event that did something wrong, but I can't find anything.
Any ideas how to debug this? The unhandled exception seems to be coming from a reject call in WritableStreamWrapper write method:
and this seems to be deep inside the vscode-languageserver implementation to do with rpc or something.
I think the key might be this part of the error:
but I don't know why is not handling it in 1 second...
The text was updated successfully, but these errors were encountered: