godotengine / godot-vscode-plugin

Godot development tools for VSCode
MIT License
1.58k stars 168 forks source link

Language server stuck "Initializing" #435

Closed OsamaHeweitat closed 1 year ago

OsamaHeweitat commented 2 years ago

Godot version

3.5.1

VS Code version

1.73.0

Godot Tools VS Code extension version

1.3.1

System information

Windows 10

Issue description

Whenever VSCode is launched, regardless if through Godot or not, or whether it was launched before or after Godot, the language server status at the bottom right will be stuck as "Initializing", clicking on it will give the following popup text: "Connecting to the GDScript language server at 127.0.0.1:6007"

VSCode is actually not connecting to the language server and it isn't just a visual bug, as features such as auto-complete and debugging do not work. I tried every possible fix and nothing worked, I tried multiple versions of Godot and VSCode.

Steps to reproduce

  1. Launch VSCode.
OsamaHeweitat commented 2 years ago

The issue doesn't occur when using versions of the plugin below 1.3.0, such as 1.2.0. Using 1.3.0 and 1.3.1 causes the issue to arise again.

Calinou commented 2 years ago

cc @DaelonSuzuka

It might be worth checking whether this issue is fixed in the latest master branch: https://github.com/godotengine/godot-vscode-plugin#download

I plan to make a 1.4.0 release soon, but my availability has been scarce lately.

OsamaHeweitat commented 2 years ago

Can confirm the issue still occurs for me using the latest master branch.

DaelonSuzuka commented 2 years ago

Very interesting. I did a quick test and I can't replicate this on 1.3.0, 1.3.1, or master connecting to Godot 3.5 or 3.5.1 on Windows 10.

popup text: "Connecting to the GDScript language server at 127.0.0.1:6007"

@OsamaHeweitat This sticks out to me. The default language server port in Godot 3.x is 6008, and in Godot 4 it's 6005. Is 6007 a typo here, or have you intentionally modified your Godot editor settings to change the port to 6007?

OsamaHeweitat commented 2 years ago

Very interesting. I did a quick test and I can't replicate this on 1.3.0, 1.3.1, or master connecting to Godot 3.5 or 3.5.1 on Windows 10.

popup text: "Connecting to the GDScript language server at 127.0.0.1:6007"

@OsamaHeweitat This sticks out to me. The default language server port in Godot 3.x is 6008, and in Godot 4 it's 6005. Is 6007 a typo here, or have you intentionally modified your Godot editor settings to change the port to 6007?

I changed the port at the time to 6007 in hopes of the it working. The issue occurs with both 6008 and 6007 as the port. I tried adjusting a multitude of settings and nothing worked.

MagicPenguin301 commented 1 year ago

Have you ever checked your extension settings in your vscode to make sure that the editor path and port is correct? Because if you just moved from an older godot version and used the extension in the past, then the path will also be the older one, which will prevent it from connecting. I just encountered with this problem.

OsamaHeweitat commented 1 year ago

Have you ever checked your extension settings in your vscode to make sure that the editor path and port is correct? Because if you just moved from an older godot version and used the extension in the past, then the path will also be the older one, which will prevent it from connecting. I just encountered with this problem.

I've always made sure the editor path is correct, sadly it still didn't work.

brandonson commented 1 year ago

I had this issue when launching from godot, or when VSCode was closed/reopened after launching from godot. It looks like something, maybe this line here in activation, is dependent on a workspace directory being set, but that doesn't happen when launching from godot into a new, workspace-less window. See full error below.

I think it'd probably be enough to just wrap that in if (this.workspace_dir)? Unfortunately I'm not at all set up for vscode plugin development at the moment, so I can't really do anything to check.

Anyway, it's easy to work around. Open vscode, then use "File: Open folder" to open your game root directory from within, and it works. Also, opening the script from Godot works at that point, because vscode keeps the same window (presumably because the script is within the active project).

This is the full error from the vscode extension host log:

2022-11-13 14:00:31.467 [error] Activating extension geequlim.godot-tools failed due to an error:
2022-11-13 14:00:31.467 [error] AssertionError [ERR_ASSERTION]: `dir` parameter should be of type string. Got type: undefined
    at new Walker (/home/copied/.vscode-insiders/extensions/geequlim.godot-tools-1.3.1/node_modules/klaw/src/index.js:12:5)
    at walk (/home/copied/.vscode-insiders/extensions/geequlim.godot-tools-1.3.1/node_modules/klaw/src/index.js:69:10)
    at GodotTools.activate (/home/copied/.vscode-insiders/extensions/geequlim.godot-tools-1.3.1/out/godot-tools.js:50:9)
    at activate (/home/copied/.vscode-insiders/extensions/geequlim.godot-tools-1.3.1/out/extension.js:9:11)
    at Function._callActivateOptional (/opt/visual-studio-code-insiders/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:106:17676)
    at Function._callActivate (/opt/visual-studio-code-insiders/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:106:17336)
    at /opt/visual-studio-code-insiders/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:106:15131
    at w._activate (/opt/visual-studio-code-insiders/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:92:8266)
    at w._waitForDepsThenActivate (/opt/visual-studio-code-insiders/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:92:8208)
    at w._initialize (/opt/visual-studio-code-insiders/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:92:7572)
DaelonSuzuka commented 1 year ago

Sorry for the delay in addressing this, I've been sick for the last week or so.

I had this issue when launching from godot, or when VSCode was closed/reopened after launching from godot. It looks like something, maybe this line here in activation, is dependent on a workspace directory being set, but that doesn't happen when launching from godot into a new, workspace-less window. See full error below.

Thanks for the insight here. I think I only ever open VSCode with a folder-as-workspace, so I might never have tested this. I've wanted to clean up this initialization path for a while but obviously I didn't realize it had the potential to be this broken.

DaelonSuzuka commented 1 year ago

@OsamaHeweitat @brandonson

439 should fix this issue. If anybody wants to test it, a development build is available here