pylance-release
pylance-release copied to clipboard
Pylance server does not work after restart
I'm facing issues similar to #4121 where the language server sometimes runs out of memory and restarts. However the problem is that even after the process restarts, none of the language features work. I could reproduce this behavior by killing the process manually.
Environment data
- Language Server version: 2023.8.20 (pyright fcee52c7)
- OS and version: Linux RHEL8
- Python version (& distribution if applicable, e.g. Anaconda): 3.10.4
Repro Steps
- Open a file in a python project
- Kill the pylance server (eg:
pkill -f ms-python.vscode). Make sure it restarts. - Re-open the same or different file
- Try using Go-to-definition, which just hangs.
Expected behavior
The pylance server should work after restarting
Actual behavior
Only restarting the entire vscode process helps
Logs
After killing the language server:
2023-08-10 17:26:51.738 [info] [Info - 5:26:51 PM] Connection to server got closed. Server will restart.
2023-08-10 17:26:51.738 [info] true
2023-08-10 17:26:52.463 [info] [Info - 5:26:52 PM] (1717614) Pylance language server 2023.8.20 (pyright fcee52c7) starting
2023-08-10 17:26:52.463 [info] [Info - 5:26:52 PM] (1717614) Server root directory: [redacted]/.vscode/extensions/ms-python.vscode-pylance-2023.8.20/dist
2023-08-10 17:26:52.471 [info] [Info - 5:26:52 PM] (1717614) Starting service instance "[redacted]"
2023-08-10 17:26:52.941 [info] [Info - 5:26:52 PM] (1717614) Background analysis(1) root directory: [redacted]
2023-08-10 17:26:52.944 [info] [Info - 5:26:52 PM] (1717614) Background analysis(1) started
Can you provide us some logs as described in the troubleshooting guide?
This issue has been closed automatically because it needs more information and has not had recent activity. If the issue still persists, please reopen with the information requested. Thanks.
Hi, I was able to reproduce this issue by following the steps described by @propertone, and get a log with the "python.analysis.logLevel": "Trace" setting turned on. I'm attaching the log and some environment info as .txt files.
environment_info.txt
pylance_log.txt
FWIW, I see this message at the end of the log 2023-10-04 13:42:26.255 [info] [Error - 13:42:26] (1610536) Received redundant open text document command for /tmp/bench_res/test.py. If the file was open in the editor when I called the pkill command, then closing and re-opening the file gave me this message. If, on another attempt to reproduce the issue, I closed the file before calling pkill, then the first time I opened the file I wouldn't get the message - I'd have to close it and re-open it for this message to appear.
I'm unable to re-open the issue - could you please reopen it?
I dont see anything in the log that I would see something that can cause OOM from pylance.
2023-10-04 13:41:57.082 [info] [Info - 13:41:57] (1610536) Pylance language server 2023.9.30 (pyright 7e72aa15) starting
2023-10-04 13:41:57.082 [info] [Info - 13:41:57] (1610536) Server root directory: /home/pgavriil/.vscode-server/extensions/ms-python.vscode-pylance-2023.9.30/dist
2023-10-04 13:41:57.089 [info] [Info - 13:41:57] (1610536) Starting service instance "bench_res"
2023-10-04 13:42:26.255 [info] [Error - 13:42:26] (1610536) Received redundant open text document command for /tmp/bench_res/test.py
I see that auto restart has failed. and that's probably why no LS works after auto restart but auto restart is not something we guarantee it would work in all cases. you might sometime need to manually restart vscode (reload windows)
unfortunately, can't figure out why 2023-10-04 13:41:56.762 [info] [Info - 13:41:56] Connection to server got closed. Server will restart. happened using log.
to proceed, we probably need some kind of repro steps to repro it ourside.
can you provide this file to us? /tmp/bench_res/test.py with all dependencies we need to install?
auto restart is not something we guarantee it would work in all cases
Why is this not guaranteed to work? There are a lot of cases where the LSP crashes, but doesn't restart - this ends up being very inconvenient for a lot of users.
unfortunately, can't figure out why 2023-10-04 13:41:56.762 [info] [Info - 13:41:56] Connection to server got closed. Server will restart. happened using log.
In this case, we manually killed the process using pkill because we couldn't reproduce the crash.
In general, we observe frequent crashes but we don't have anything concrete to determine what's causing them. Given that (a) we cannot reliably reproduce these crashes, and (b) when they naturally occur, they usually involve files which we cannot share, do you have any pointers on how we could debug the Pylance extension in production? i.e. not by debugging it within VSCode on an extension development host.
We will do our best to document and sharing any findings if they'd be relevant to other users!
Thanks!
Hey @heejaechang, this issue might need further attention.
@propertone, you can help us out by closing this issue if the problem no longer exists, or adding more information.
This issue has been closed automatically because it needs more information and has not had recent activity. If the issue still persists, please reopen with the information requested. Thanks.