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

Failed to start and restart clangd #406

Closed
fonqL opened this issue Oct 27, 2022 · 13 comments · Fixed by #461
Closed

Failed to start and restart clangd #406

fonqL opened this issue Oct 27, 2022 · 13 comments · Fixed by #461
Labels
bug Something isn't working

Comments

@fonqL
Copy link

fonqL commented Oct 27, 2022

Please describe the problem.

image

Simply translate: Command ... resulted in an error ...

But 0.1.22 works well.

Logs
No output

System information
Clangd version (from the log, or clangd --version):

clangd version 14.0.3
Features: windows
Platform: x86_64-pc-windows-msvc

clangd extension version:
0.1.23

VScode version:
1.69.1

Operating system:
Win10

@fonqL fonqL added the bug Something isn't working label Oct 27, 2022
@HighCommander4
Copy link
Contributor

When this happens, can you open Help --> Toggle Developer Tools, and copy what you see in the Console tab? Hopefully there is a stack trace there that gives more information about this error.

@fonqL
Copy link
Author

fonqL commented Oct 29, 2022

vscode-app-1667030779566.log

Here are logs, but I can't find anything related to clang(d)... Hope it will help you.

@fonqL
Copy link
Author

fonqL commented Nov 4, 2022

After debugging the extension I find my previous config clangd.path: D:\LLVM\bin\clangd is regarded as an error, and it is solved by appending .exe.
A little weird...
This problem is related to @clangd/install 0.1.16. (When I modified @clangd/install dependency version to 0.1.4 it works well)
The location of the exception is here.
image

Or, is it actually my fault..?
If yes, I hope it can log something or show a dialog...

@HighCommander4
Copy link
Contributor

Thanks, I can reproduce the original error now.

Steps to reproduce:

  1. Set clangd.path to an invalid path
  2. Close and restart vscode
    ==> At this point, on vscode startup, I get a dialog saying: "The clangd binary '<path>' was not found. Would you like to download and install clangd 15.0.3"?
  3. Close that dialog (without installing).
  4. Perform "clangd: Restart language server"

Now I get the error:

Command 'clangd: Restart language server' resulted in an error (Cannot read properties of undefined (reading 'stop'))

The source of the error is the this.client.stop() call here. That code is triggered by 'clangd: Restart language server', and it expects this.client to be a valid object, but if clangd was not running to begin with, then it will be undefined.

This part is a vscode-clangd bug.

As for D:\LLVM\bin\clangd being an invalid path on Windows, I think that's a legitimate error. Since the filename does include the .exe, the value of clangd.path should as well. I understand it may have worked without the .exe before since some library facilities try to automatically add the .exe, it's probably not a good idea to rely on that.

Out of curiosity, do you not get the first dialog (from step 2) when starting vscode, which says "The clangd binary 'D:\LLVM\bin\clangd' was not found. Would you like to download and install clangd 15.0.3"?

@fonqL
Copy link
Author

fonqL commented Nov 4, 2022

Yes, I've never seen the dialog even if the path doesn't exist.
I can't find any code calling promptInstall.

@HighCommander4
Copy link
Contributor

I can't find any code calling promptInstall.

The code is in node-clangd

@fonqL
Copy link
Author

fonqL commented Nov 6, 2022

I have tried my best but still have no idea.
It seems that the code after this await doesn't get executed at all. When I click next step button in that line, in typescript it just returns to here, in javascript it jumps to the end of __awaiter() in that recover function.
Debug console has no logs.
I can only guess:

  1. The status has a background member which is a Promise. After await common.prepare it seems to be ignored, and its status is pending, though I don't know what it means. I try to await or .then/.catch but none of these works.
  2. Network problems when accessing github cause some strange problems. But it seems never timeout or throw something.

@fonqL
Copy link
Author

fonqL commented Nov 7, 2022

Ok I finally figured it out. It's a network and timeout problem. My vscode can't access github smoothly because of unknown reasons, and there is also no timeout parameter set in latestRelease function which is called by recover function.
I think you can reproduce by disconnecting the internet.

@HighCommander4
Copy link
Contributor

Ok I finally figured it out. It's a network and timeout problem. My vscode can't access github smoothly because of unknown reasons, and there is also no timeout parameter set in latestRelease function which is called by recover function. I think you can reproduce by disconnecting the internet.

Thanks for investigating! That sounds like a second bug that we should fix in node-clangd.

@fonqL fonqL closed this as completed Nov 8, 2022
@HighCommander4
Copy link
Contributor

(I'm going to reopen this issue and use it to track fixes for the two vscode-clangd/node-clangd bugs we have identified.)

@HighCommander4 HighCommander4 reopened this Nov 8, 2022
HighCommander4 added a commit to HighCommander4/vscode-clangd that referenced this issue Feb 27, 2023
this.client may not have been set if activate() failed for
some reason (e.g. the clangd executable could not be found
and the user opted not to install it via auto-install)

Partially fixes clangd#406
@HighCommander4
Copy link
Contributor

Fix for the first issue: #461

HighCommander4 added a commit to HighCommander4/node-clangd that referenced this issue Feb 27, 2023
This avoids the auto-install process hanging if the github
website is unresponsive for some reason.

Fixes the remaining issue in clangd/vscode-clangd#406
@HighCommander4
Copy link
Contributor

Fix for the second issue: clangd/node-clangd#23

(Though I could not reproduce the hang locally -- if I disconnect my internet then the fetch() fails immediately. That said, I'm fairly confident that adding a timeout here should address the hang.)

hokein pushed a commit that referenced this issue Feb 28, 2023
this.client may not have been set if activate() failed for
some reason (e.g. the clangd executable could not be found
and the user opted not to install it via auto-install)

Partially fixes #406
@fonqL
Copy link
Author

fonqL commented Feb 28, 2023

It works, thanks a lot!

(Though I could not reproduce the hang locally -- if I disconnect my internet then the fetch() fails immediately. That said, I'm fairly confident that adding a timeout here should address the hang.)

I just found out that it is related to my network proxy.

HighCommander4 added a commit to HighCommander4/node-clangd that referenced this issue Mar 1, 2023
This avoids the auto-install process hanging if the github
website is unresponsive for some reason.

Fixes the remaining issue in clangd/vscode-clangd#406
HighCommander4 added a commit to HighCommander4/node-clangd that referenced this issue Mar 1, 2023
This avoids the auto-install process hanging if the github
website is unresponsive for some reason.

Fixes the remaining issue in clangd/vscode-clangd#406
dankeboy36 pushed a commit to dankeboy36/install-from-gh-to-vscode that referenced this issue Dec 6, 2023
This avoids the auto-install process hanging if the github
website is unresponsive for some reason.

Fixes the remaining issue in clangd/vscode-clangd#406
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

Successfully merging a pull request may close this issue.

2 participants