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

Using Pylance on Remote Machine #6159

Closed
AnsonSavage opened this issue Jul 19, 2024 · 24 comments
Closed

Using Pylance on Remote Machine #6159

AnsonSavage opened this issue Jul 19, 2024 · 24 comments
Assignees
Labels
needs repro Issue has not been reproduced yet

Comments

@AnsonSavage
Copy link

Similar to this issue: #5245

While using SSH to work remotely in VS Code, I got this error:

Screenshot from 2024-07-17 08-50-18

I resolved this error by setting the path to Node explicitly here:

Screenshot from 2024-07-17 08-52-27

However, now I get these kinds of errors:

Screenshot from 2024-07-18 12-21-04

The corresponding output is:

2024-07-18 12:20:58.161 [info] Error: Cannot call write after a stream was destroyed
    at _write (node:internal/streams/writable:483:11)
    at Socket.Writable.write (node:internal/streams/writable:502:10)
    at /home/ansonsav/.vscode-server/extensions/ms-python.python-2024.10.0-linux-x64/out/client/extension.js:2:1980580
    at new Promise (<anonymous>)
    at a.write (/home/ansonsav/.vscode-server/extensions/ms-python.python-2024.10.0-linux-x64/out/client/extension.js:2:1980498)
    at b.doWrite (/home/ansonsav/.vscode-server/extensions/ms-python.python-2024.10.0-linux-x64/out/client/extension.js:2:1968027)
    at /home/ansonsav/.vscode-server/extensions/ms-python.python-2024.10.0-linux-x64/out/client/extension.js:2:1967922
2024-07-18 12:20:58.726 [info] [Info  - 12:20:58 PM] (849176) Pylance language server 2024.7.1 (pyright version 1.1.369, commit 1168be71) starting
2024-07-18 12:20:58.726 [info] [Info  - 12:20:58 PM] (849176) Server root directory: file:///home/ansonsav/.vscode-server/extensions/ms-python.vscode-pylance-2024.7.1/dist
2024-07-18 12:20:58.737 [info] [Info  - 12:20:58 PM] (849176) Starting service instance "archive"

Environment data

  • Pylance version: v2024.7.1
  • OS and version: RHEL 9 (accessed through SSH from Ubuntu 22.04)
  • Python version: 3.9.18

Logs

I've enabled logging, but I don't see any output. When I do something like press F12 on a Python variable, I just see the blue loading bar with no output.

Thanks!
Anson

@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Jul 19, 2024
@rchiodo
Copy link
Contributor

rchiodo commented Jul 19, 2024

Thanks for the issue. What's your version of node on the remote machine?

@rchiodo
Copy link
Contributor

rchiodo commented Jul 19, 2024

Logging should be here (although it looks like it's crashing immediately:

image

If you're using an older node, you might try upgrading. VS code ships with 20.9.0, so specifying your own node, you might need to have a similar version.

@AnsonSavage
Copy link
Author

Ahh, okay. I couldn't find that dropdown in the UI, but the system administrators I was working with had me point it to v18.19.1.

@rchiodo
Copy link
Contributor

rchiodo commented Jul 19, 2024

If you restart does it work? That error might have been because you set the node executable but didn't restart VS code (the Python extension was attempting to shutdown the old version maybe).

@AnsonSavage
Copy link
Author

Good point. I've both restarted VS Code and reconnected to the remote several times.

@rchiodo
Copy link
Contributor

rchiodo commented Jul 19, 2024

Might be something about node on your remote machine then. You can try the command we run internally yourself to see if it gives you any extra output.

it should be something like:

<path to node> \home\username\.vscode-server\extensions\<pylance extension path>\dist\server.bundle.js

Sometimes global node environment variables can make running node by itself not work for us.

Alternatively we could try and figure out why using the VS code node crashed/ran out of memory.

@AnsonSavage
Copy link
Author

Okay!

I got this output after running that command:


You may install and use any number of copies of the software only with Microsoft Visual Studio, Visual Studio for Mac, Visual Studio Code, Azure DevOps, Team Foundation Server, and successor Microsoft products and services (collectively, the “Visual Studio Products and Services”) to develop and test your applications. The software is licensed, not sold. This agreement only gives you some rights to use the software. Microsoft reserves all other rights. You may not: work around any technical limitations in the software that only allow you to use it in certain ways; reverse engineer, decompile or disassemble the software, or otherwise attempt to derive the source code for the software, except and to the extent required by third party licensing terms governing use of certain open source components that may be included in the software; remove, minimize, block, or modify any notices of Microsoft or its suppliers in the software; use the software in any way that is against the law or to create or propagate malware; or share, publish, distribute, or lease the software (except for any distributable code, subject to the terms above), provide the software as a stand-alone offering for others to use, or transfer the software or this agreement to any third party.

I would also be down to learn why VS Code's node ran out of memory.

@rchiodo
Copy link
Contributor

rchiodo commented Jul 19, 2024

That output is actually expected, it's what happens when Pylance runs without VS code, but that means it didn't crash which is good/bad (bad in that we don't have an easy way to figure out why VS code is crashing pylance).

Can you share your source? That would be the easiest way to figure out the memory problem. We can reproduce it in house and analyze all the data.

You can e-mail the source too if you don't want to share it publicly. My e-mail is my github id at microsoft.com.

If you can't share the source, you might try some other techiques listed at the help for the python.analysis.nodeExecutable setting: https://github.com/microsoft/pylance-release/blob/main/TROUBLESHOOTING.md#pylance-is-crashing

Like:

  • Increasing memory allowed for vscode remote
  • excluding unneeded files

We'd rather just make our software use less memory though if we can reproduce the issue.

@AnsonSavage
Copy link
Author

Hello! I think I can, what does sharing the source mean?

@rchiodo
Copy link
Contributor

rchiodo commented Jul 19, 2024

The easiest way is if your source code is in a public github repository. Then we just git clone your source and try to reproduce the issue.

Otherwise you'd likely need to send or upload a zip file of the source.

@AnsonSavage
Copy link
Author

Ah, I see!

The problem persists regardless of what repo I'm working in remotely.

@rchiodo
Copy link
Contributor

rchiodo commented Jul 22, 2024

So any python code will cause pylance to crash?

@rchiodo
Copy link
Contributor

rchiodo commented Jul 22, 2024

Can you get logs for pylance and upload them according to the directions here?

https://github.com/microsoft/pylance-release/blob/main/TROUBLESHOOTING.md#filing-an-issue

@rchiodo
Copy link
Contributor

rchiodo commented Jul 22, 2024

I may have made an incorrect assumption, that you were running out of memory. Something else might be causing a crash.

@AnsonSavage
Copy link
Author

Okay! Here's what I've seen this morning:

2024-07-24 09:57:57.273 [info] [Info  - 9:57:57 AM] (3216640) Pylance language server 2024.7.1 (pyright version 1.1.369, commit 1168be71) starting
2024-07-24 09:57:57.273 [info] [Info  - 9:57:57 AM] (3216640) Server root directory: file:///home/ansonsav/.vscode-server/extensions/ms-python.vscode-pylance-2024.7.1/dist
2024-07-24 09:57:57.284 [info] [Info  - 9:57:57 AM] (3216640) Starting service instance "archive"
2024-07-24 10:03:40.328 [info] 
<--- Last few GCs --->

[3216640:0x55e2ac0]   338812 ms: Mark-sweep 8043.1 (8227.0) -> 8037.7 (8237.3) MB, 5946.1 / 0.0 ms  (average mu = 0.474, current mu = 0.145) allocation failure; scavenge might not succeed
[3216640:0x55e2ac0]   343807 ms: Mark-sweep 8053.5 (8237.3) -> 8046.2 (8245.3) MB, 4941.1 / 0.0 ms  (average mu = 0.306, current mu = 0.011) allocation failure; scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

2024-07-24 10:03:40.329 [info]  1: 0xb91950 node::Abort() [/apps/nodejs/18.19.1/gcc-11.3.1/bin/node]

2024-07-24 10:03:40.330 [info]  2: 0xa85713  [/apps/nodejs/18.19.1/gcc-11.3.1/bin/node]

2024-07-24 10:03:40.330 [info]  3: 0xd758b0 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/apps/nodejs/18.19.1/gcc-11.3.1/bin/node]

2024-07-24 10:03:40.331 [info]  4: 0xd75c46 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/apps/nodejs/18.19.1/gcc-11.3.1/bin/node]

2024-07-24 10:03:40.332 [info]  5: 0xf5e645  [/apps/nodejs/18.19.1/gcc-11.3.1/bin/node]

2024-07-24 10:03:40.332 [info]  6: 0xf6ec7d v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/apps/nodejs/18.19.1/gcc-11.3.1/bin/node]

2024-07-24 10:03:40.333 [info]  7: 0xf47bea v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/apps/nodejs/18.19.1/gcc-11.3.1/bin/node]

2024-07-24 10:03:40.334 [info]  8: 0xf48e04 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/apps/nodejs/18.19.1/gcc-11.3.1/bin/node]

2024-07-24 10:03:40.335 [info]  9: 0xf2780d v8::internal::Factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/apps/nodejs/18.19.1/gcc-11.3.1/bin/node]

2024-07-24 10:03:40.335 [info] 10: 0x1315b1d v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/apps/nodejs/18.19.1/gcc-11.3.1/bin/node]

2024-07-24 10:03:40.336 [info] 11: 0x1775fb9  [/apps/nodejs/18.19.1/gcc-11.3.1/bin/node]

2024-07-24 10:03:42.066 [info] [Info  - 10:03:42 AM] Connection to server got closed. Server will restart.
2024-07-24 10:03:42.066 [info] true
2024-07-24 10:03:42.079 [info] [Error - 10:03:42 AM] Server process exited with signal SIGABRT.
2024-07-24 10:03:42.946 [info] [Info  - 10:03:42 AM] (3236372) Pylance language server 2024.7.1 (pyright version 1.1.369, commit 1168be71) starting
2024-07-24 10:03:42.946 [info] [Info  - 10:03:42 AM] (3236372) Server root directory: file:///home/ansonsav/.vscode-server/extensions/ms-python.vscode-pylance-2024.7.1/dist
2024-07-24 10:03:42.958 [info] [Info  - 10:03:42 AM] (3236372) Starting service instance "archive"

Interestingly, since it crashed and restarted, it hasn't crashed again but it also hasn't been able to perform any Python Language features (e.g., identify variables, go to variable references, etc.)

Thanks!

@zuliani99
Copy link

zuliani99 commented Jul 24, 2024

I solved this issue by upating node to the latest available version and by changing the following setting:

python.analysis.nodeExecutable = "/home/your_user/.nvm/versions/node/v20.16.0/bin/node"

I hope this will help...

@rchiodo
Copy link
Contributor

rchiodo commented Jul 24, 2024

@AnsonSavage that is an out of memory problem. So my original assumption was correct.

We'd need access to the source code you're using in order to reproduce the issue. The directory with all of your python code in it.

You might also try what @zuliani99 suggested and upgrade your node executable.

@AnsonSavage
Copy link
Author

Okay. I'm logged in to a remote node that has many subfolders and many repositories. From the workspace root, there are 282260 Python files. (I'm assuming that this is what is causing Pylance to crash.)

However, it is helpful to use VSCode and log in such that I can see all the folders on our entire system. Is it possible to tell Pylance that I want to limit its processing to a directory and its subdirectories so that it's only processing and managing the Python for the particular code that I'm working on?

@rchiodo
Copy link
Contributor

rchiodo commented Jul 24, 2024

Yes actually there's a description of how to do that here:
https://github.com/microsoft/pylance-release/blob/main/TROUBLESHOOTING.md#exclude-unneeded-py-files-from-analysis

You can exclude everything you're not currently working on using the python.analysis.include and the python.analysis.exclude settings.

They're also described in more detail here:
https://microsoft.github.io/pyright/#/configuration?id=main-configuration-options

@AnsonSavage
Copy link
Author

Okay, so say I'm coding in RLL_co-detr directory.

clean_paths

Could I create an additional .vscode and settings.json file like this?

@rchiodo
Copy link
Contributor

rchiodo commented Jul 24, 2024

You would need to do that in the root though, not in that folder. Pylance is analyzing the entire workspace so it would still include everything else.

or you could just open that folder directly and setup your 'extraPaths' in the .vscode/settings.json to include the folder(s) you need to load imports.

@AnsonSavage
Copy link
Author

Ah, I see! Okay, I'll give that a try. Thank you!

@AnsonSavage
Copy link
Author

Awesome, that looks like it worked!!

Thank you so much!
Anson

@rchiodo
Copy link
Contributor

rchiodo commented Jul 24, 2024

THanks, glad it worked.

@rchiodo rchiodo closed this as completed Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs repro Issue has not been reproduced yet
Projects
None yet
Development

No branches or pull requests

4 participants