microsoft / vscode-jupyter

VS Code Jupyter extension
https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter
MIT License
1.3k stars 294 forks source link

Jupyter notebook hangs (ERR NO notebook document) #16193

Open Sjlver opened 2 weeks ago

Sjlver commented 2 weeks ago

Applies To

What happened?

The notebook hangs (Go To button has a spinner, all other buttons do nothing).

This issue was originally reported at https://github.com/microsoft/pylance-release/issues/6330. I'm moving it here since it also happens with Pylance disabled. Apologies if this isn't the right place.

It is tricky to provide exact reproduction instructions, even though the problem starts to happen quite consistently after a few minutes. My best guess is that the problem happens when a syntax error is introduced:

Notebook state:

import pandas as pd
import numpy as np
df = pd.DataFrame(
    np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]),
    columns=['a', 'b', 'c']
)
df.loc["a"] = ?
with pd.option_context("display.max_rows", 100):
    display(df)

Something like this appears in the "Problems" tab:

[{
    "resource": "/home/jbw/repro/repro.ipynb",
    "owner": "python",
    "severity": 8,
    "message": "SyntaxError: invalid syntax (repro.ipynb#W1sdnNjb2RlLXJlbW90ZQ%3D%3D, line 5)",
    "source": "compile",
    "startLineNumber": 5,
    "startColumn": 7,
    "endLineNumber": 5,
    "endColumn": 8
}]

Python language server output shows 2024-10-29 10:24:14.352 [info] [Error - 10:24:14 AM] (29738) Received change text document command for closed file file:///home/jbw/repro/repro.ipynb.py#W1sdnNjb2RlLXJlbW90ZQ%3D%3D

Dev tools show:

INFO Started local extension host with pid 16768.
log.ts:419  INFO Invoking resolveAuthority(wsl)...
log.ts:419  INFO [LocalProcess0][resolveAuthority(wsl,1)][0ms] obtaining proxy...
log.ts:419  INFO [LocalProcess0][resolveAuthority(wsl,1)][0ms] invoking...
log.ts:419  INFO [LocalProcess0][resolveAuthority(wsl,1)][673ms] returned WebSocket(127.0.0.1:64537)
log.ts:419  INFO resolveAuthority(wsl) returned 'WebSocket(127.0.0.1:64537)' after 673 ms
log.ts:419  INFO Creating a socket (renderer-Management-1a6e70f9-e3f5-4011-b5d7-cae4c94381d8)...
log.ts:419  INFO Creating a socket (renderer-ExtensionHost-1c2c5d40-e559-48a4-92e2-5efa718cae8d)...
log.ts:419  INFO Creating a socket (renderer-Management-1a6e70f9-e3f5-4011-b5d7-cae4c94381d8) was successful after 92 ms.
log.ts:419  INFO Creating a socket (renderer-ExtensionHost-1c2c5d40-e559-48a4-92e2-5efa718cae8d) was successful after 234 ms.
TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope source.sql.
Old grammar file: file:///c%3A/Users/ltlyg/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/extensions/sql/syntaxes/sql.tmLanguage.json.
New grammar file: vscode-remote://wsl%2Bubuntu/home/REDACTED/.vscode-server/extensions/mtxr.sqltools-0.28.3/language/sql.tmLanguage.json
register @ TMScopeRegistry.ts:46
TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope source.sql.
Old grammar file: file:///c%3A/Users/ltlyg/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/extensions/sql/syntaxes/sql.tmLanguage.json.
New grammar file: vscode-remote://wsl%2Bubuntu/home/REDACTED/.vscode-server/extensions/mtxr.sqltools-0.28.3/language/sql.tmLanguage.json
register @ TMScopeRegistry.ts:46
log.ts:419  INFO [perf] Render performance baseline is 71ms
console.ts:137 [Extension Host] Checking whether to register object drop extension
console.ts:137 [Extension Host] Registering object drop provider
console.ts:137 [Extension Host] Registered object drop provider
webviewElement.ts:486 An iframe which has both allow-scripts and allow-same-origin for its sandbox attribute can escape its sandboxing.
mountTo @ webviewElement.ts:486
webviewElement.ts:486 An iframe which has both allow-scripts and allow-same-origin for its sandbox attribute can escape its sandboxing.
mountTo @ webviewElement.ts:486
log.ts:439   ERR adding EXISTING notebook file:///home/REDACTED/repro/repro.ipynb : Error: adding EXISTING notebook file:///home/REDACTED/repro/repro.ipynb 
    at nh.$acceptDocumentAndEditorsDelta (file:///home/REDACTED/.vscode-server/bin/384ff7382de624fb94dbaf6da11977bba1ecd427/out/vs/workbench/api/node/extensionHostProcess.js:155:13379)
    at Zb.S (file:///home/REDACTED/.vscode-server/bin/384ff7382de624fb94dbaf6da11977bba1ecd427/out/vs/workbench/api/node/extensionHostProcess.js:31:155752)
    at Zb.Q (file:///home/REDACTED/.vscode-server/bin/384ff7382de624fb94dbaf6da11977bba1ecd427/out/vs/workbench/api/node/extensionHostProcess.js:31:155532)
...
    at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
    at Readable.push (node:internal/streams/readable:390:5)
    at TCP.onStreamRead (node:internal/stream_base_commons:191:23)
console.ts:137 [Extension Host] info 10:21:51.536: Jupyter Extension: Starting Kernel (Python Path: ~/repro/.venv/bin/python, Venv, 3.10.12) for '~/repro/repro.ipynb' (disableUI=true)
console.ts:137 [Extension Host] info 10:21:52.122: Jupyter Extension: Process Execution: ~/repro/.venv/bin/python -m pip list
console.ts:137 [Extension Host] info 10:21:52.131: Jupyter Extension: Process Execution: ~/repro/.venv/bin/python -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
console.ts:137 [Extension Host] info 10:21:52.138: Jupyter Extension: Process Execution: ~/repro/.venv/bin/python -m ipykernel_launcher --f=/home/REDACTED/.local/share/jupyter/runtime/kernel-v3c760129574c1c4f791a671aa5abb4f29fba272a9.json
    > cwd: //home/REDACTED/repro
console.ts:137 [Extension Host] info 10:21:53.045: Jupyter Extension: Kernel successfully started
console.ts:137 [Extension Host] info 10:21:53.053: Jupyter Extension: Process Execution: ~/repro/.venv/bin/python /home/REDACTED/.vscode-server/extensions/ms-toolsai.jupyter-2024.9.1-linux-x64/pythonFiles/printJupyterDataDir.py
2console.ts:137 [Extension Host] info 10:22:52.327: Jupyter Extension: Disposing request as the cell (1) was deleted ~/repro/repro.ipynb
console.ts:137 [Extension Host] info 10:22:52.328: Jupyter Extension: Dispose Kernel '~/repro/repro.ipynb' associated with '~/repro/repro.ipynb'
webviewElement.ts:486 An iframe which has both allow-scripts and allow-same-origin for its sandbox attribute can escape its sandboxing.
mountTo @ webviewElement.ts:486
console.ts:137 [Extension Host] info 10:23:03.746: Jupyter Extension: Starting Kernel (Python Path: ~/repro/.venv/bin/python, Venv, 3.10.12) for '~/repro/repro.ipynb' (disableUI=true)
console.ts:137 [Extension Host] info 10:23:03.760: Jupyter Extension: Process Execution: ~/repro/.venv/bin/python -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
console.ts:137 [Extension Host] info 10:23:03.804: Jupyter Extension: Process Execution: ~/repro/.venv/bin/python -m ipykernel_launcher --f=/home/REDACTED/.local/share/jupyter/runtime/kernel-v3dda9f9854777fe6546710fa3c5bd581b9b534a63.json
    > cwd: //home/REDACTED/repro
console.ts:137 [Extension Host] info 10:23:04.663: Jupyter Extension: Kernel successfully started
webviewElement.ts:486 An iframe which has both allow-scripts and allow-same-origin for its sandbox attribute can escape its sandboxing.
mountTo @ webviewElement.ts:486
console.ts:137 [Extension Host] info 10:24:09.854: Jupyter Extension: Dispose Kernel '~/repro/repro.ipynb' associated with '~/repro/repro.ipynb'
log.ts:439   ERR unknown text editor: 1ddaceb1-9613-4685-bdb2-ee6adfc8d152. known editors:  : Error: unknown text editor: 1ddaceb1-9613-4685-bdb2-ee6adfc8d152. known editors:  
    at nh.getEditorById (file:///home/REDACTED/.vscode-server/bin/384ff7382de624fb94dbaf6da11977bba1ecd427/out/vs/workbench/api/node/extensionHostProcess.js:155:5598)
    at wb.$acceptEditorPropertiesChanged (file:///home/REDACTED/.vscode-server/bin/384ff7382de624fb94dbaf6da11977bba1ecd427/out/vs/workbench/api/node/extensionHostProcess.js:155:16972)
    at Zb.S (file:///home/REDACTED/.vscode-server/bin/384ff7382de624fb94dbaf6da11977bba1ecd427/out/vs/workbench/api/node/extensionHostProcess.js:31:155752)
...
    at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
    at Readable.push (node:internal/streams/readable:390:5)
    at TCP.onStreamRead (node:internal/stream_base_commons:191:23)
log.ts:439   ERR NO notebook document for 'file:///home/REDACTED/repro/repro.ipynb': Error: NO notebook document for 'file:///home/REDACTED/repro/repro.ipynb'
    at nh.getNotebookDocument (file:///home/REDACTED/.vscode-server/bin/384ff7382de624fb94dbaf6da11977bba1ecd427/out/vs/workbench/api/node/extensionHostProcess.js:155:5868)
    at DU.$acceptModelChanged (file:///home/REDACTED/.vscode-server/bin/384ff7382de624fb94dbaf6da11977bba1ecd427/out/vs/workbench/api/node/extensionHostProcess.js:155:16411)
    at Zb.S (file:///home/REDACTED/.vscode-server/bin/384ff7382de624fb94dbaf6da11977bba1ecd427/out/vs/workbench/api/node/extensionHostProcess.js:31:155752)
...
    at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
    at Readable.push (node:internal/streams/readable:390:5)
    at TCP.onStreamRead (node:internal/stream_base_commons:191:23)
log.ts:429  WARN Error: NO notebook document for 'file:///home/REDACTED/repro/repro.ipynb'
    at nh.getNotebookDocument (file:///home/REDACTED/.vscode-server/bin/384ff7382de624fb94dbaf6da11977bba1ecd427/out/vs/workbench/api/node/extensionHostProcess.js:155:5868)
    at IU.$participateInSave (file:///home/REDACTED/.vscode-server/bin/384ff7382de624fb94dbaf6da11977bba1ecd427/out/vs/workbench/api/node/extensionHostProcess.js:155:15492)
    at Zb.S (file:///home/REDACTED/.vscode-server/bin/384ff7382de624fb94dbaf6da11977bba1ecd427/out/vs/workbench/api/node/extensionHostProcess.js:31:155752)
    at Zb.Q (file:///home/REDACTED/.vscode-server/bin/384ff7382de624fb94dbaf6da11977bba1ecd427/out/vs/workbench/api/node/extensionHostProcess.js:31:155532)
    at Zb.M (file:///home/REDACTED/.vscode-server/bin/384ff7382de624fb94dbaf6da11977bba1ecd427/out/vs/workbench/api/node/extensionHostProcess.js:31:154583)
...
    at addChunk (node:internal/streams/readable:559:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
    at Readable.push (node:internal/streams/readable:390:5)
    at TCP.onStreamRead (node:internal/stream_base_commons:191:23)
log.ts:439   ERR NO notebook document for 'file:///home/REDACTED/repro/repro.ipynb': Error: NO notebook document for 'file:///home/REDACTED/repro/repro.ipynb'
    at nh.getNotebookDocument (file:///home/REDACTED/.vscode-server/bin/384ff7382de624fb94dbaf6da11977bba1ecd427/out/vs/workbench/api/node/extensionHostProcess.js:155:5868)
    at DU.$acceptDirtyStateChanged (file:///home/REDACTED/.vscode-server/bin/384ff7382de624fb94dbaf6da11977bba1ecd427/out/vs/workbench/api/node/extensionHostProcess.js:155:16528)
    at Zb.S (file:///home/REDACTED/.vscode-server/bin/384ff7382de624fb94dbaf6da11977bba1ecd427/out/vs/workbench/api/node/extensionHostProcess.js:31:155752)
    at Zb.Q (file:///home/REDACTED/.vscode-server/bin/384ff7382de624fb94dbaf6da11977bba1ecd427/out/vs/workbench/api/node/extensionHostProcess.js:31:155532)
...
    at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
    at Readable.push (node:internal/streams/readable:390:5)
    at TCP.onStreamRead (node:internal/stream_base_commons:191:23)
log.ts:439   ERR NO notebook document for 'file:///home/REDACTED/repro/repro.ipynb': Error: NO notebook document for 'file:///home/REDACTED/repro/repro.ipynb'
    at nh.getNotebookDocument (file:///home/REDACTED/.vscode-server/bin/384ff7382de624fb94dbaf6da11977bba1ecd427/out/vs/workbench/api/node/extensionHostProcess.js:155:5868)
    at DU.$acceptModelSaved (file:///home/REDACTED/.vscode-server/bin/384ff7382de624fb94dbaf6da11977bba1ecd427/out/vs/workbench/api/node/extensionHostProcess.js:155:16612)
    at Zb.S (file:///home/REDACTED/.vscode-server/bin/384ff7382de624fb94dbaf6da11977bba1ecd427/out/vs/workbench/api/node/extensionHostProcess.js:31:155752)
...
    at Readable.push (node:internal/streams/readable:390:5)
    at TCP.onStreamRead (node:internal/stream_base_commons:191:23)
log.ts:439   ERR unknown text editor: 1ddaceb1-9613-4685-bdb2-ee6adfc8d152. known editors:  : Error: unknown text editor: 1ddaceb1-9613-4685-bdb2-ee6adfc8d152. known editors:  
    at nh.getEditorById (file:///home/REDACTED/.vscode-server/bin/384ff7382de624fb94dbaf6da11977bba1ecd427/out/vs/workbench/api/node/extensionHostProcess.js:155:5598)
    at wb.$acceptEditorPropertiesChanged (file:///home/REDACTED/.vscode-server/bin/384ff7382de624fb94dbaf6da11977bba1ecd427/out/vs/workbench/api/node/extensionHostProcess.js:155:16972)
    at Zb.S (file:///home/REDACTED/.vscode-server/bin/384ff7382de624fb94dbaf6da11977bba1ecd427/out/vs/workbench/api/node/extensionHostProcess.js:31:155752)
...
    at Readable.push (node:internal/streams/readable:390:5)
    at TCP.onStreamRead (node:internal/stream_base_commons:191:23)
log.ts:439   ERR NO notebook document for 'file:///home/REDACTED/repro/repro.ipynb': Error: NO notebook document for 'file:///home/REDACTED/repro/repro.ipynb'
    at nh.getNotebookDocument (file:///home/REDACTED/.vscode-server/bin/384ff7382de624fb94dbaf6da11977bba1ecd427/out/vs/workbench/api/node/extensionHostProcess.js:155:5868)
    at DU.$acceptModelChanged (file:///home/REDACTED/.vscode-server/bin/384ff7382de624fb94dbaf6da11977bba1ecd427/out/vs/workbench/api/node/extensionHostProcess.js:155:16411)
    at Zb.S (file:///home/REDACTED/.vscode-server/bin/384ff7382de624fb94dbaf6da11977bba1ecd427/out/vs/workbench/api/node/extensionHostProcess.js:31:155752)
...
    at Readable.push (node:internal/streams/readable:390:5)
    at TCP.onStreamRead (node:internal/stream_base_commons:191:23)
log.ts:439   ERR NO notebook document for 'file:///home/REDACTED/repro/repro.ipynb': Error: NO notebook document for 'file:///home/REDACTED/repro/repro.ipynb'
    at nh.getNotebookDocument (file:///home/REDACTED/.vscode-server/bin/384ff7382de624fb94dbaf6da11977bba1ecd427/out/vs/workbench/api/node/extensionHostProcess.js:155:5868)
    at bb.$cellExecutionChanged (file:///home/REDACTED/.vscode-server/bin/384ff7382de624fb94dbaf6da11977bba1ecd427/out/vs/workbench/api/node/extensionHostProcess.js:155:25626)
...
    at Readable.push (node:internal/streams/readable:390:5)
    at TCP.onStreamRead (node:internal/stream_base_commons:191:23)
4log.ts:439   ERR unknown text editor: 1ddaceb1-9613-4685-bdb2-ee6adfc8d152. known editors:  : Error: unknown text editor: 1ddaceb1-9613-4685-bdb2-ee6adfc8d152. known editors:  
    at nh.getEditorById (file:///home/REDACTED/.vscode-server/bin/384ff7382de624fb94dbaf6da11977bba1ecd427/out/vs/workbench/api/node/extensionHostProcess.js:155:5598)
    at wb.$acceptEditorPropertiesChanged (file:///home/REDACTED/.vscode-server/bin/384ff7382de624fb94dbaf6da11977bba1ecd427/out/vs/workbench/api/node/extensionHostProcess.js:155:16972)
    at Zb.S (file:///home/REDACTED/.vscode-server/bin/384ff7382de624fb94dbaf6da11977bba1ecd427/out/vs/workbench/api/node/extensionHostProcess.js:31:155752)
    at Zb.Q (file:///home/REDACTED/.vscode-server/bin/384ff7382de624fb94dbaf6da11977bba1ecd427/out/vs/workbench/api/node/extensionHostProcess.js:31:155532)
...
    at Readable.push (node:internal/streams/readable:390:5)
    at TCP.onStreamRead (node:internal/stream_base_commons:191:23)

VS Code Version

Version: 1.94.2 (user setup) Commit: 384ff7382de624fb94dbaf6da11977bba1ecd427 Date: 2024-10-09T16:08:44.566Z Electron: 30.5.1 ElectronBuildId: 10262041 Chromium: 124.0.6367.243 Node.js: 20.16.0 V8: 12.4.254.20-electron.0 OS: Windows_NT x64 10.0.22631

Jupyter Extension Version

2024.9.1

Jupyter logs

No response

Coding Language and Runtime Version

Python 3.10.12

Language Extension Version (if applicable)

2024.16.1

Anaconda Version (if applicable)

No response

Running Jupyter locally or remotely?

Local

DonJayamanne commented 2 weeks ago

Thank you for reporting this issue. Please can you verify this issue repros with

Create a new folder, a venv, start code, create a notebook. Add some content to the notebook. My test case contains the two cells below. Do a bit of editing, including adding things that would cause syntax errors.

So I can try to repro this at my end, please can you

vs-code-engineering[bot] commented 1 week ago

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

Sjlver commented 1 week ago

Sorry for the delay on this; I wasn't able to try again sooner.

I can confirm that this still happens if all extensions except Python and Jupyter are disabled.

I'm currently using the latest versions (I think):

Version: 1.95.2 (user setup)
Commit: e8653663e8840adaf45af01eab5c627a5af81807
Date: 2024-11-07T11:07:22.054Z
Electron: 32.2.1
ElectronBuildId: 10427718
Chromium: 128.0.6613.186
Node.js: 20.18.0
V8: 12.8.374.38-electron.0
OS: Windows_NT x64 10.0.22631
Name: Jupyter
Id: ms-toolsai.jupyter
Description: Jupyter notebook support, interactive programming and computing that supports Intellisense, debugging and more.
Version: 2024.10.0
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter
Name: Python
Id: ms-python.python
Description: Python language support with extension access points for IntelliSense (Pylance), Debugging (Python Debugger), linting, formatting, refactoring, unit tests, and more.
Version: 2024.20.0
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-python.python

By start code, I mean typing code . into my WSL2 terminal, after having activated the venv. This starts VSCode.

Normally, it takes some time for the problem to manifest. I've seen it once on the very first run of a cell. More often, I work in notebooks for a few minutes, and then I notice the problem. I haven't found a deterministic trigger yet, sorry.

Sjlver commented 1 week ago

I found that this reproduces consistently if I just wait for a while (a few minutes). No other user action seems to be needed.

I've just tested this with a notebook where the single cell was:

Image

Console shows both: ERR adding EXISTING notebook file:///home/jbw/redacted/py/test.ipynb : Error: adding EXISTING notebook file:///home/jbw/projects/healthlearn/py/test.ipynb ERR NO notebook document for 'file:///home/jbw/redacted/py/test.ipynb': Error: NO notebook document for 'file:///home/jbw/projects/healthlearn/py/test.ipynb'

Jupyter: show output

Visual Studio Code (1.95.2, wsl, desktop)
Jupyter Extension Version: 2024.10.0.
Python Extension Version: 2024.20.0.
Pylance Extension not installed.
Platform: linux (x64).
Temp Storage folder ~/.vscode-server/data/User/globalStorage/ms-toolsai.jupyter/version-2024.10.0
Workspace folder ~/redacted/py, Home = /home/jbw
20:26:07.341 [info] Starting Kernel (Python Path: ~/redacted/py/.venv/bin/python, Venv, 3.10.12) for '~/redacted/py/test.ipynb' (disableUI=true)
20:26:08.067 [info] Process Execution: ~/redacted/py/.venv/bin/python -m pip list
20:26:08.086 [info] Process Execution: ~/redacted/py/.venv/bin/python -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
20:26:08.100 [info] Process Execution: ~/redacted/py/.venv/bin/python -m ipykernel_launcher --f=/home/~/.local/share/jupyter/runtime/kernel-v342e11cad248a2f91373b16eb1accfcb7d8f1aa52.json
    > cwd: //home/~/redacted/py
20:26:09.064 [info] Kernel successfully started
20:26:09.072 [info] Process Execution: ~/redacted/py/.venv/bin/python /home/~/.vscode-server/extensions/ms-toolsai.jupyter-2024.10.0-linux-x64/pythonFiles/printJupyterDataDir.py
20:29:04.834 [info] Dispose Kernel '~/redacted/py/test.ipynb' associated with '~/redacted/py/test.ipynb'

@DonJayamanne Would you mind re-opening this auto-closed issue? Thanks! Let me know if you need further information from me.

nesaboz commented 1 day ago

Same issue here. I'm constantly running into it, few cells into execution, or 1-2 min, it crashes seemingly out of nowhere. It's not workload specific.

I have limited time to troubleshoot, not in a position to disable all extensions. I'll post more info when I can (my workaround is to not use jupyter in VSCode), just wanted to chime in so it gets visibility since it's quite annoying.

vsee commented 16 hours ago

Hi, I am seeing the same issue and heard reports from at least four colleagues about the same thing. I see similar behavior: a few minutes after opening the Notebook, it crashes out of nowhere, I can't see related error messages and when I try to execute cells again I get the No Document message. I noticed that syntax highlighting turns off so I thought it is related to pylance. Disabling pylance, however, does not resolve it.

DonJayamanne commented 1 hour ago

Please can you disable all extensions except for Python, Jupyter and Notebook Renderers. Let me know if that makes a difference.