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

Pylance crashes when using the interactive window #6357

Closed
MarceloAritaAdvisia opened this issue Sep 6, 2024 · 29 comments
Closed

Pylance crashes when using the interactive window #6357

MarceloAritaAdvisia opened this issue Sep 6, 2024 · 29 comments
Assignees
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@MarceloAritaAdvisia
Copy link

Environment data

  • Pylance version: v2024.8.2
  • OS and version: Windows 11
  • Python version (& distribution if applicable, e.g. Anaconda): 3.10.14

Code Snippet

import torch
import numpy as np

Repro Steps

  1. Open a Python file in Visual Studio Code.
  2. Start using the Pylance extension.
  3. Observe that Pylance crashes multiple times within a few minutes.

Expected behavior

Pylance should run without crashing and provide proper linting, autocompletion, and code analysis for Python files.

Actual behavior

Pylance crashes repeatedly within a few minutes of usage, and it does not restart automatically.

Logs

untitled:/Interactive-1.interactive.py
    at _0x4c4f8d (c:\Users\your-username\.vscode\extensions\ms-python.vscode-pylance-2024.8.2\dist\server.bundle.js:1:1072956)
    at _0xc0b312 (c:\Users\your-username\.vscode\extensions\ms-python.vscode-pylance-2024.8.2\dist\server.bundle.js:1:1077607)
    at _0x508620 (c:\Users\your-username\.vscode\extensions\ms-python.vscode-pylance-2024.8.2\dist\server.bundle.js:1:1078049)
    at c:\Users\your-username\.vscode\extensions\ms-python.vscode-pylance-2024.8.2\dist\server.bundle.js:1:1004156

2024-09-06 08:41:14.121 [info] [Error - 8:41:14 AM] Pylance has crashed 5 times in the last 3 minutes. Pylance will not be restarted. Please check [this link](https://aka.ms/AApf7ox) for more details.
@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Sep 6, 2024
@rchiodo
Copy link
Contributor

rchiodo commented Sep 6, 2024

Thanks for the issue. Unfortunately, we cannot reproduce the problem. Can you include the Python Language Server output as described here:
https://github.com/microsoft/pylance-release/blob/main/TROUBLESHOOTING.md#filing-an-issue

That should show what's crashing in Pylance.

@rchiodo rchiodo added the waiting for user response Requires more information from user label Sep 6, 2024
@cddesja
Copy link

cddesja commented Sep 9, 2024

I am having a similar problem. See the attached log file. I couldn't paste it here as it was too long.
pylance_log.md

@rchiodo
Copy link
Contributor

rchiodo commented Sep 9, 2024

@cddesja your problem is this:

2024-09-09 09:46:57.541 [info] Error: Debug Failure. False expression: Duplicate path in cellFilePaths: untitled:/Interactive-4.interactive.py#W1sdW50aXRsZWQ%3D
untitled:/Interactive-4.interactive.py#W2sdW50aXRsZWQ%3D
untitled:/Interactive-4.interactive.py#W3sdW50aXRsZWQ%3D
untitled:/Interactive-4.interactive.py#W4sdW50aXRsZWQ%3D

Looks like a bug in our interactive window handling. Same as this issue here:
#6366

@rchiodo
Copy link
Contributor

rchiodo commented Sep 9, 2024

I'm able to reproduce following these steps here:

  1. Create a python file with # %% cells
  2. Execute a cell
  3. Reload vscode without closing the interactive window
  4. Execute another cell

Error shows up.

@rchiodo rchiodo added bug Something isn't working and removed waiting for user response Requires more information from user needs repro Issue has not been reproduced yet labels Sep 9, 2024
@rchiodo rchiodo changed the title Pylance crashes repeatedly and does not restart in VS Code on Windows 11 Pylance crashes when using the interactive window Sep 9, 2024
@rchiodo
Copy link
Contributor

rchiodo commented Sep 9, 2024

Hmm, in VS code insiders the interactive window behaves differently. It doesn't reoutput the cells from before the reload, preventing the problem from occurring.

@debonte
Copy link
Contributor

debonte commented Sep 9, 2024

Might be related to the DidOpenTextDocumentFeature.register code that this old issue is talking about? microsoft/vscode-languageserver-node#1394

@rchiodo
Copy link
Contributor

rchiodo commented Sep 9, 2024

I think this is a bug in the vscode-languageclient-npm module. We're getting a did change event that has an impossible start index.

During the onDidNotebookDocumentChange event, the start index for the NotebookCellArrayChange looks like it's including the markdown cells. It doesn't normally.

This only happens when I restart.

@rchiodo
Copy link
Contributor

rchiodo commented Sep 9, 2024

Nope, it was a bug in our own code. Maybe VS code started adding markdown cells to the interactive notebook recently and they weren't there before. The problem is we're not accounting for markdown cells when adding the Interactive input to the bottom of our cell list.

@bschnurr bschnurr added the fixed in next version (main) A fix has been implemented and will appear in an upcoming version label Sep 9, 2024
@ernimd
Copy link

ernimd commented Sep 10, 2024

Still an issue with Last updated 2024-09-10, 09:40:38 : (

@rben01
Copy link

rben01 commented Sep 10, 2024

I am also seeing this. I can confirm that the repro is opening/restoring a VSCode workspace with an existing ipython pane (created by running # %% cells) open.

Extensions: Pylance v2024.9.1, Python v2024.14.0.

Pylance logs:

2024-09-10 10:29:49.332 [info] Error: Debug Failure. False expression: Duplicate path in cellFilePaths: untitled:/Interactive-1.interactive.py#W1sdW50aXRsZWQ%3D



untitled:/Interactive-1.interactive.py
    at _0x3b1d9a (/Users/rben01/.vscode/extensions/ms-python.vscode-pylance-2024.9.1/dist/server.bundle.js:1:1040515)
    at _0x3c03f1 (/Users/rben01/.vscode/extensions/ms-python.vscode-pylance-2024.9.1/dist/server.bundle.js:1:1044937)
    at _0x4e65cb (/Users/rben01/.vscode/extensions/ms-python.vscode-pylance-2024.9.1/dist/server.bundle.js:1:1045372)
    at /Users/rben01/.vscode/extensions/ms-python.vscode-pylance-2024.9.1/dist/server.bundle.js:1:1001232

2024-09-10 10:29:49.344 [info] [Error - 10:29:49 AM] Server process exited with code 1.
2024-09-10 10:29:49.346 [info] [Error - 10:29:49 AM] Pylance has crashed 5 times in the last 3 minutes. Pylance will not be restarted. Please check [this link](https://aka.ms/AApf7ox) for more details.

@rchiodo
Copy link
Contributor

rchiodo commented Sep 10, 2024

Yes, the fix for this hasn't shipped yet. It should ship sometime this week.

@alejandro979
Copy link

Thanks @rchiodo experiencing the same issue as the other folks. It is crashing non stop. I did put nodejs for pylance and also expanded the amount memory. Nothing seems to be working.

@alejandro979
Copy link

Here are the logs for my case:
[2024-09-10 134649.323 [info] Error.log

@rchiodo
Copy link
Contributor

rchiodo commented Sep 10, 2024

@alejandro979 your issue doesn't look to be the same problem. Are you using an interactive window? If not, it's something different. I recommend opening a new issue and add a full log as described here:
https://github.com/microsoft/pylance-release/blob/main/TROUBLESHOOTING.md#filing-an-issue

@alejandro979
Copy link

@rchiodo Yes. I'm using the interactive window. Do you still feel like I should open a new issue? Thank you

@rchiodo
Copy link
Contributor

rchiodo commented Sep 10, 2024

No, it's just weird that it's not logging the same error. Maybe your trace level isn't high enough.

Likely the same problem though.

Our interactive window logic is just wrong. VS code must have updated to include markdown cells in the interactive window or otherwise it should have never worked.

@d-walkama
Copy link

+1 for issue, following for fix.

@dempc6469
Copy link

+1 for issue, following for fix.

what he said .....

@PrateekArya
Copy link

Temp. fix: Close all interactive windows and restart VSCode. Pylance works perfectly then!

But there should be a setting to auto close all interactive windows while exiting VSCode. Added a feature request in VSCode (microsoft/vscode#228206)! 😊

@luohancfd
Copy link

I'm so annoyed and disappointed by this issue. Microsoft develops both the pylance extension and the jupyter one. Have you guys even done a test before rolling out the update? What do you mean by #6235 (comment)?

You can workaround the issue by closing all interactive windows and restarting VS code

This is not a workaround but a compromise. If you can't roll out a hotfix, at least should provide the version of the extension without the bug

@luohancfd
Copy link

This is a fix: just uninstall pylance and install the old school jedi-language-server

@rchiodo
Copy link
Contributor

rchiodo commented Sep 11, 2024

If you can't roll out a hotfix, at least should provide the version of the extension without the bug

There is no version of the Pylance extension without this bug. It's existed since we added interactive window support. Rolling back VS code to 1.89 might fix the issue, but then you'd also have to rollback other things as well.

@rchiodo
Copy link
Contributor

rchiodo commented Sep 11, 2024

I've confirmed you can also rollback VS code to 1.89 and the problem went away for me. The Python Extension, the Pylance Extension, and the Jupyter Extension have to be rolled back to much older versions as well.

@Carolinah23
Copy link

Hi, I am reporting that I am having the same bug since yesterday.

2024-09-12 15:27:58.023 [info] [Error - 3:27:58 PM] Server process exited with code 1.
2024-09-12 15:27:58.023 [info] Error: Debug Failure. False expression: Chained file path untitled:/Interactive-1.interactive.py#pylancePrefixCell doesn't match cellFilePaths undefined
    at _0x3b1d9a (c:\Users\carol\.vscode\extensions\ms-python.vscode-pylance-2024.9.1\dist\server.bundle.js:1:1040945)
    at _0x3c03f1 (c:\Users\carol\.vscode\extensions\ms-python.vscode-pylance-2024.9.1\dist\server.bundle.js:1:1044937)
    at _0x4e65cb (c:\Users\carol\.vscode\extensions\ms-python.vscode-pylance-2024.9.1\dist\server.bundle.js:1:1045372)
    at c:\Users\carol\.vscode\extensions\ms-python.vscode-pylance-2024.9.1\dist\server.bundle.js:1:1001232

2024-09-12 15:27:58.027 [info] [Error - 3:27:58 PM] Pylance has crashed 5 times in the last 3 minutes. Pylance will not be restarted. Please check [this link](https://aka.ms/AApf7ox) for more details.

After several crashes, I installed the 2023.10.30 version, which seems to work fine.

@StellaHuang95
Copy link
Contributor

This issue has been fixed in prerelease version 2024.9.100, which we've just released. You can find the changelog here: CHANGELOG.md

@polidore
Copy link

polidore commented Sep 13, 2024 via email

@cshjin
Copy link

cshjin commented Sep 18, 2024

A temp fix from my side: pkill -u $USER, if there are no critical jobs running, and restart vscode.

@scaomath
Copy link

scaomath commented Oct 4, 2024

I am still experiencing issues regarding the interactive window with 2024.9.2.
Rolling back to 2024.8.2 solves the issue.

@rchiodo
Copy link
Contributor

rchiodo commented Oct 4, 2024

I am still experiencing issues regarding the interactive window with 2024.9.2.

Yes, this is expected. You have to upgrade to the 2024.9.100 version (or newer). The 100 is newer than 2 in our version scheme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version
Projects
None yet
Development

No branches or pull requests