Skip to content

No diagnostic logging when remote kernel reconnection fails with SessionDisposedError #17358

@dimaordercapital

Description

@dimaordercapital

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

  1. Connect to a remote Jupyter server (e.g., jupyter lab --no-browser --port=8889)
  2. Open a notebook, select a kernel, run a cell — works fine
  3. Restart the kernel on the server side (e.g., via JupyterLab browser UI or API) — kernel ID changes
  4. Restart VS Code
  5. 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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions