Bug Description
When reconnecting to a remote Jupyter server after VS Code restart, if the previously stored kernel ID no longer matches a live kernel on the server, the extension throws SessionDisposedError ("Cannot execute code, session has been disposed") with no diagnostic logging explaining why reconnection failed.
The user sees only the generic error message with no way to understand what went wrong without reading the source code.
Steps to Reproduce
- Connect to a remote Jupyter server (e.g.,
jupyter lab --no-browser --port=8889)
- Open a notebook, select a kernel, run a cell — works fine
- Restart the kernel on the server side (e.g., via JupyterLab browser UI or API) — kernel ID changes
- Restart VS Code
- Try to run a cell → "Cannot execute code, session has been disposed"
The stored preferredRemoteKernelId in Memento no longer matches any live kernel, but nothing is logged to explain this.
Expected Behavior
Diagnostic logs at key decision points so users (and developers) can trace why reconnection failed. For example:
preferredKernelConnectionService.ts: "Looking for stored kernel ID X among N discovered kernels. No match found."
jupyterKernelSessionFactory.ts: "Attempting reconnection to kernel ID X" / "Reconnection failed: kernel not found"
remoteKernelFinder.ts: "Cached kernel X no longer present on server"
cellExecution.ts: "Session disposed — kernel ID: X, session status: Y, isDisposed: Z"
Logging Gap Analysis
After reading the source, here's what I found:
| Component |
What should be logged |
What is logged |
preferredKernelConnectionService.ts |
Stored kernel ID, discovered kernels, match result |
Nothing — zero log statements in the file |
jupyterKernelSessionFactory.ts |
Reconnection attempt and outcome |
Only logs new session creation, not reconnection |
remoteKernelFinder.ts |
Which cached kernels disappeared |
Only logs kernel count, not IDs |
cellExecution.ts |
Kernel/session state when disposed |
Generic "Cell completed with errors" with no context |
The most critical gap is preferredKernelConnectionService.ts — this is where the stored kernel ID is looked up against live kernels, and undefined is silently returned when no match is found. The entire reconnection decision pipeline is invisible in logs.
Environment
- VS Code Jupyter Extension: v2025.9.1
- Jupyter Server: 2.17.0
- Remote connection via
jupyter lab
Additional Context
The error itself is reasonable — auto-recovering from a kernel swap could be confusing. But the lack of logging makes it very hard to diagnose. Even logger.warn level messages at the key decision points would make this transparent.
Bug Description
When reconnecting to a remote Jupyter server after VS Code restart, if the previously stored kernel ID no longer matches a live kernel on the server, the extension throws
SessionDisposedError("Cannot execute code, session has been disposed") with no diagnostic logging explaining why reconnection failed.The user sees only the generic error message with no way to understand what went wrong without reading the source code.
Steps to Reproduce
jupyter lab --no-browser --port=8889)The stored
preferredRemoteKernelIdin Memento no longer matches any live kernel, but nothing is logged to explain this.Expected Behavior
Diagnostic logs at key decision points so users (and developers) can trace why reconnection failed. For example:
preferredKernelConnectionService.ts: "Looking for stored kernel IDXamongNdiscovered kernels. No match found."jupyterKernelSessionFactory.ts: "Attempting reconnection to kernel IDX" / "Reconnection failed: kernel not found"remoteKernelFinder.ts: "Cached kernelXno longer present on server"cellExecution.ts: "Session disposed — kernel ID:X, session status:Y, isDisposed:Z"Logging Gap Analysis
After reading the source, here's what I found:
preferredKernelConnectionService.tsjupyterKernelSessionFactory.tsremoteKernelFinder.tscellExecution.tsThe most critical gap is
preferredKernelConnectionService.ts— this is where the stored kernel ID is looked up against live kernels, andundefinedis silently returned when no match is found. The entire reconnection decision pipeline is invisible in logs.Environment
jupyter labAdditional Context
The error itself is reasonable — auto-recovering from a kernel swap could be confusing. But the lack of logging makes it very hard to diagnose. Even
logger.warnlevel messages at the key decision points would make this transparent.