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

crash when notebooks are present in the workspace and diagnosticMode is "workspace" #1055

Closed
willofferfit opened this issue Feb 10, 2025 · 8 comments · Fixed by #1065
Closed

Comments

@willofferfit
Copy link

willofferfit commented Feb 10, 2025

I just updated to v1.27.0 and the extension is panicking. Previous version works fine.

IDE info (cursor)

Version: 0.45.11
VSCode Version: 1.96.2
Commit: f5f18731406b73244e0558ee7716d77c8096d150
Date: 2025-02-07T09:43:58.555Z
Electron: 32.2.6
Chromium: 128.0.6613.186
Node.js: 20.18.1
V8: 12.8.374.38-electron.0
OS: Darwin arm64 23.5.0

Error logs

[Info  - 12:52:01 PM] basedpyright language server 1.27.0 starting
[Info  - 12:52:01 PM] Server root directory: file:///Users/redacted/.cursor/extensions/detachhead.basedpyright-1.27.0/dist
[Info  - 12:52:01 PM] Starting service instance "redacted"
Received pythonPath from Python extension: /Users/redacted/.venv/bin/python
Error: failed to get lsp uri for cell at index 0 or file:///Users/redacted/redacted.ipynb#0
    at d.convertUriToLspUriString (/Users/redacted/.cursor/extensions/detachhead.basedpyright-1.27.0/dist/pyright-internal/src/languageServerBase.ts:401:23)
    at d.convertDiagnostics (/Users/redacted/.cursor/extensions/detachhead.basedpyright-1.27.0/dist/pyright-internal/src/languageServerBase.ts:1494:23)
    at d.sendDiagnostics (/Users/redacted/.cursor/extensions/detachhead.basedpyright-1.27.0/dist/pyright-internal/src/languageServerBase.ts:1681:52)
    at forEach (/Users/redacted/.cursor/extensions/detachhead.basedpyright-1.27.0/dist/pyright-internal/src/languageServerBase.ts:1511:18)
    at Array.forEach (<anonymous>)
    at d.onAnalysisCompletedHandler (/Users/redacted/.cursor/extensions/detachhead.basedpyright-1.27.0/dist/pyright-internal/src/languageServerBase.ts:1506:29)
    at u._onAnalysisCompletion (/Users/redacted/.cursor/extensions/detachhead.basedpyright-1.27.0/dist/pyright-internal/src/languageServerBase.ts:306:57)
    at u.handleBackgroundResponse (/Users/redacted/.cursor/extensions/detachhead.basedpyright-1.27.0/dist/pyright-internal/src/backgroundAnalysisBase.ts:301:22)
    at listener (/Users/redacted/.cursor/extensions/detachhead.basedpyright-1.27.0/dist/pyright-internal/src/backgroundAnalysisBase.ts:63:84)
    at MessagePort.<anonymous> (/Users/redacted/.cursor/extensions/detachhead.basedpyright-1.27.0/dist/pyright-internal/src/common/nodeWorkersHost.ts:47:43)
    at MessagePort.[nodejs.internal.kHybridDispatch] (node:internal/event_target:820:20)
    at MessagePort.<anonymous> (node:internal/per_context/messageport:23:28)
[Error - 12:52:02 PM] Server process exited with code 1.
[Error - 12:52:02 PM] The basedpyright server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.
@DetachHead
Copy link
Owner

looks like it's failing on that jupyter notebook file. are you able to provide the content of that notebook or at least a cut down version of it that reproduces the issue?

@DetachHead DetachHead added language server awaiting response waiting for more info from the author - will eventually close if they don't respond labels Feb 10, 2025
@willofferfit
Copy link
Author

{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "v = 10"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}

@RagelVarma
Copy link

Just a guess, but it works fine on small/individual notebooks. Only when you set the analysis mode to 'workspace' / analyse huge jupyter files, does the server become unable to process. This is due to VSCode unable to dedicate enough memory to the Language Servers.

I believe both the Pylance and the Typescript Extensions allow you to load the Language Servers with an External Node Executable, to start the Language Server as an external process rather than a VSCode Sub-process. Since Pylance is closed-source, a peek at the in-built Typescript extension source code might reveal how exactly does this offloading to external Node Executable works.

@willofferfit
Copy link
Author

@RagelVarma it could be that. I tried trimming down my repo to the bare minimum, until I had only two notebooks left. Each has about 250 LOC. If I keep both, I get the aforementioned error. If I delete one, or the other, then basedpyright works. This proves the issue is not my setup or the notebooks themselves

@DetachHead
Copy link
Owner

does it happen if you cut down the size of the notebooks? if you could provide the contents of both notebooks that would help me reproduce it

@willofferfit
Copy link
Author

I was able to create a minimal example.

Extract example.zip, open only a.ipynb on cursor, and it will fail with the aforementioned error. If you open both notebooks or only b.ipynb, then it works.

You also need in User/settings.json:

    "python.languageServer": "None",
    "basedpyright.analysis.diagnosticMode": "workspace",

@willofferfit
Copy link
Author

FWIW, I tried the same on vscodium v1.94.0 and observed the issue

@DetachHead DetachHead added needs investigation awaiting verification by a maintainer that the issue is valid jupyter notebooks and removed awaiting response waiting for more info from the author - will eventually close if they don't respond labels Feb 12, 2025
@DetachHead DetachHead changed the title v 1.27.0 broken crash when two notebooks are present in the workspace and diagnosticMode is "workspace" Feb 12, 2025
@DetachHead DetachHead removed the needs investigation awaiting verification by a maintainer that the issue is valid label Feb 12, 2025
@DetachHead
Copy link
Owner

reproduced, thanks

@DetachHead DetachHead changed the title crash when two notebooks are present in the workspace and diagnosticMode is "workspace" crash when notebooks are present in the workspace and diagnosticMode is "workspace" Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants