microsoft / pylance-release

Documentation and issues for Pylance
Creative Commons Attribution 4.0 International
1.7k stars 767 forks source link

Remote extension host terminates unexpectedly #5864

Open SKra00 opened 5 months ago

SKra00 commented 5 months ago

Type: Bug

I am remote SSHing into a Linux server from a Windows machine using VSCode. I have the pylance extension, but as soon as I login to the server it restarts the remote extension host several times before giving up and occasionally kicking me out of the server. I used the extension bisect tool in VSCode, which determined that pylance was the cause. Disabling the extension fixes the problem. I have also tried downgrading the extension which has allowed me to remain connected for slightly longer, but not forever. (Apologies if this is not descriptive enough, I am happy to supply more information.)

Extension version: 2024.5.1 VS Code version: Code 1.89.0 (b58957e67ee1e712cebf466b995adf4c5307b2bd, 2024-05-01T02:09:22.859Z) OS version: Windows_NT x64 10.0.22631 Modes: Connection to 'ssh-remote+ap2002.chtc.wisc.edu' could not be established

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz (8 x 1992)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|undefined| |Memory (System)|15.88GB (2.88GB free)| |Process Argv|--crash-reporter-id d100a373-6af0-4ce5-92e5-3770ea91b189| |Screen Reader|no| |VM|0%| Connection to 'ssh-remote+ap2002.chtc.wisc.edu' could not be established
A/B Experiments ``` vsliv368cf:30146710 vspor879:30202332 vspor708:30202333 vspor363:30204092 tftest:31042121 vscorecescf:30445987 vscod805cf:30301675 binariesv615:30325510 vsaa593cf:30376535 py29gd2263:31024239 c4g48928:30535728 azure-dev_surveyone:30548225 962ge761:30959799 pythongtdpath:30769146 welcomedialogc:30910334 pythonidxpt:30866567 pythonnoceb:30805159 asynctok:30898717 pythontestfixt:30902429 pythonregdiag2:30936856 pyreplss1:30897532 pythonmypyd1:30879173 pythoncet0:30885854 2e7ec940:31000449 pythontbext0:30879054 accentitlementst:30995554 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:31000557 dsvsc020:30976470 pythonait:31006305 dsvsc021:30996838 g316j359:31013175 a69g1124:31038041 pythonprt:31039817 dwnewjupytercf:31039676 ```
heejaechang commented 5 months ago

Can you provide us some logs as described in the troubleshooting guide?

SKra00 commented 5 months ago

Can you provide us some logs as described in the troubleshooting guide?

I tried to enable the trace log level (at the User, Remote Server, and Workspace levels) but the Python Language Server output contains nothing at all. Is there another log I can provide that would contain the needed information?

StellaHuang95 commented 5 months ago

When you say "contains nothing at all", do you mean there's no output at all in the Python Language Server output? Not sure how could that happen. Can you share a screenshot of that? and your settings.json?

SKra00 commented 5 months ago

When you say "contains nothing at all", do you mean there's no output at all in the Python Language Server output? Not sure how could that happen. Can you share a screenshot of that? and your settings.json?

Here is a screenshot of the Python Language Server output: image

And here is a screenshot of the Python output just to show that this is not a more general output problem: image

Here is the text of the settings.json file:

{
    "editor.minimap.enabled": false,
    "jupyter.askForKernelRestart": false,
    "python.autoComplete.extraPaths": [],
    "python.analysis.extraPaths": [],
    "remote.SSH.remotePlatform": {
        "ap2002.chtc.wisc.edu": "linux"
    },
    "python.defaultInterpreterPath": "C:\\ProgramData\\anaconda3\\envs\\<USER'S NAME>\\python.exe",
    "git.ignoreLegacyWarning": true,
    "remote.SSH.useExecServer": false,
    "python.analysis.logLevel": "Trace",
    "python.analysis.packageIndexDepths": [
        {
            "name": "sklearn",
            "depth": 2
        },
        {
            "name": "matplotlib",
            "depth": 2
        },
        {
            "name": "scipy",
            "depth": 2
        },
        {
            "name": "django",
            "depth": 2
        },
        {
            "name": "flask",
            "depth": 2
        },
        {
            "name": "fastapi",
            "depth": 2
        }
    ]
}
heejaechang commented 5 months ago

if you are using remote and multi root workspace, make sure you are putting settings in right place and share the right setting files.

you should have settings section similar to this for your remote/workspace/folder image

the precedence of setting will be folder > workspace > remote

and some setting can only applied to certain scope. for example, you can't put logLevel to folder but in workspace and up and etc.

heejaechang commented 5 months ago

since it looks like pylance is crashing even before starting server, you probably can't use https://github.com/microsoft/pylance-release/wiki/Collecting-data-for-an-investigation.#collecting-trace-logs-using-commands but if you somehow could manage to make server to start you could use the command to get log we need.

SKra00 commented 5 months ago

if you are using remote and multi root workspace, make sure you are putting settings in right place and share the right setting files.

you should have settings section similar to this for your remote/workspace/folder image

the precedence of setting will be folder > workspace > remote

and some setting can only applied to certain scope. for example, you can't put logLevel to folder but in workspace and up and etc.

I have set the loglevel setting to Trace at the User, Remote, and Workspace levels just to make sure I had the right one. The Folder option does not have this setting available as far as I can tell.

SKra00 commented 5 months ago

since it looks like pylance is crashing even before starting server, you probably can't use https://github.com/microsoft/pylance-release/wiki/Collecting-data-for-an-investigation.#collecting-trace-logs-using-commands but if you somehow could manage to make server to start you could use the command to get log we need.

I have used slightly downgraded versions of pylance recently that will successfully load/connect for a while before restarting the remote extension host. I just connected with v2024.2.3 and was able to get output in the Python Language Server. I will wait to see if the restart issue occurs and report back with the output.

SKra00 commented 4 months ago

After downgrading to v2024.2.1, I was able to connect to my remote ssh with pylance functioning properly, but after waiting some time in the editor pylance seemed to stutter and disconnect. It attempted to reconnect a couple times before successfully doing so. I am attaching the python language server output starting at the moment it initially disconnected.

Please note: this is NOT the exact issue I have with newer versions of pylance. If I use the most recent version, it fails to connect at all upon logging in through the ssh process. pylance python language server output v2024.2.1.txt

heejaechang commented 4 months ago

I can not see any issue on pylance log, it looks like pylance extension suddenly restarted. can you look other logs in the output window and see whether it contains error message such as remote got disconnected? if you see one, can you share that log with us? it might be an issue with vscode remote and we just happen to restarted since vscode-server got re-initialized.

SKra00 commented 4 months ago

I can not see any issue on pylance log, it looks like pylance extension suddenly restarted. can you look other logs in the output window and see whether it contains error message such as remote got disconnected? if you see one, can you share that log with us? it might be an issue with vscode remote and we just happen to restarted since vscode-server got re-initialized.

I monitored a couple of the logs while trying to recreate the issue, but I could not seem to identify any that would provide useful information as to what is happening. Here is the list of logs available: image

For example, Extension Host (Remote) seemed promising, but it appears to clear/restart whenever this occurs, so I cannot see what happened prior to the issue occurring.

Are there any you would like to see specifically?

heejaechang commented 4 months ago

how about remote - SSH log? does it contain anything interesting there?

SKra00 commented 4 months ago

how about remote - SSH log? does it contain anything interesting there?

Nothing is very interesting in that log either. For example, here is all the additional output produced by this issue occurring once:

[16:17:13.840] [Forwarding server port 52873] Got connection 9

The integer at the end increases every time this happens (starts at 1).

heejaechang commented 4 months ago

could it be something related to something like this? https://stackoverflow.com/questions/64172004/vscode-ssh-extension-keeps-disconnecting-after-moving-to-a-new-location

SKra00 commented 4 months ago

could it be something related to something like this? https://stackoverflow.com/questions/64172004/vscode-ssh-extension-keeps-disconnecting-after-moving-to-a-new-location

I tried the suggested solution of removing the .vscode-server and .vscode-remote (this second one did not exist in my case, so I only removed the first one), but it did not fix the issue. The Remote Extension host still terminates upon logging in via ssh when using the most recent version of pylance.