vscode-jupyter: jupyter notebooks hanging on "Detecting Kernels"

Applies To

  • Notebooks (.ipynb files)
  • Interactive Window and/or Cell Scripts (.py files with #%% markers)

What happened?

  1. Run jupyterlab in WSL, control it from vscode (this has been working for me for months).
  2. Open vscode with a jupyter notebook.
  3. The notebook opens, in the upper right corner there is a spinner and “Detecting Kernels”
  4. I try to clear the kernel MRU, select another kernel, enter the jupyter URL, etc, etc, nothing appears to work. --> I expected this to connect and allow me to run the notebook!
  5. Close vscode
  6. Next time I open VS Code, it hangs with a blank screen for a while and then my it opens with my notebook showing as a blank page and throws the error: “Error loading webview: Error: Could not register service workers: InvalidStateError: Failed to register a ServiceWorker: The document is in an invalid state…” [sic]

VS Code Version

Version: 1.76.0 (user setup) Commit: 92da9481c0904c6adfe372c12da3b7748d74bdcb Date: 2023-03-01T10:22:44.506Z Electron: 19.1.11 Chromium: 102.0.5005.196 Node.js: 16.14.2 V8: 10.2.154.26-electron.0 OS: Windows_NT x64 10.0.22621 Sandboxed: No

Jupyter Extension Version

v2023.2.1000592019

Jupyter logs

Visual Studio Code (1.76.0, undefined, desktop)
Jupyter Extension Version: 2023.2.1000592019.
Python Extension Version: 2023.4.0.
Workspace folder c:\Users\natha\code\venera
User belongs to experiment group 'jupyterTestcf'
User belongs to experiment group 'jupyterEnhancedDataViewer'
info 15:27:21.105: LSP Notebooks experiment is enabled
info 15:27:21.145: Checking for server existence.
info 15:27:21.145: Checking for server existence.
info 15:27:21.145: Checking for server existence.
info 15:27:21.146: Connecting to server
info 15:27:21.146: Connecting to server
info 15:27:21.146: Connecting to server
info 15:27:21.146: Connecting remote server kernel http://localhost:8888
Connecting to Jupyter server at http://localhost:8888
info 15:27:21.146: Connecting remote server kernel http://localhost:8888
Connecting to Jupyter server at http://localhost:8888
info 15:27:21.146: Connecting remote server kernel http://localhost:8888
Connecting to Jupyter server at http://localhost:8888
info 15:27:21.146: Creating server with url : http://localhost:8888
info 15:27:21.148: Creating server with url : http://localhost:8888
info 15:27:21.149: Creating server with url : http://localhost:8888
info 15:27:21.154: Server started.
info 15:27:21.154: Server started.
info 15:27:21.154: Server started.
info 15:27:21.154: Creating server with url : http://localhost:8888
info 15:27:21.154: Creating server with url : http://localhost:8888
info 15:27:21.154: Creating server with url : http://localhost:8888
error 15:27:21.180: Error fetching remote kernels: [t [Error]: Forbidden
	at t.create (c:\Users\natha\.vscode\extensions\ms-toolsai.jupyter-2023.2.1000592019\out\extension.node.js:2:68927)
	at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
	at async t.listRunning (c:\Users\natha\.vscode\extensions\ms-toolsai.jupyter-2023.2.1000592019\out\extension.node.js:2:56792)
	at async ug.getRunningKernels (c:\Users\natha\.vscode\extensions\ms-toolsai.jupyter-2023.2.1000592019\out\extension.node.js:17:270516)
	at async Promise.all (index 0)
	at async yg.listKernelsFromConnection (c:\Users\natha\.vscode\extensions\ms-toolsai.jupyter-2023.2.1000592019\out\extension.node.js:17:281216)] {
  response: L [Response] {
    size: 0,
    timeout: 0,
    [Symbol(Body internals)]: { body: [PassThrough], disturbed: true, error: null },
    [Symbol(Response internals)]: {
      url: 'http://localhost:8888/api/kernels?1677788841156',
      status: 403,
      statusText: 'Forbidden',
      headers: [T [Headers]],
      counter: 0
    }
  },
  traceback: ''
}
error 15:27:21.184: Error fetching remote kernels: [t [Error]: Forbidden
	at t.create (c:\Users\natha\.vscode\extensions\ms-toolsai.jupyter-2023.2.1000592019\out\extension.node.js:2:68927)
	at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
	at async t.listRunning (c:\Users\natha\.vscode\extensions\ms-toolsai.jupyter-2023.2.1000592019\out\extension.node.js:2:56792)
	at async ug.getRunningKernels (c:\Users\natha\.vscode\extensions\ms-toolsai.jupyter-2023.2.1000592019\out\extension.node.js:17:270516)
	at async Promise.all (index 0)
	at async yg.listKernelsFromConnection (c:\Users\natha\.vscode\extensions\ms-toolsai.jupyter-2023.2.1000592019\out\extension.node.js:17:281216)] {
  response: L [Response] {
    size: 0,
    timeout: 0,
    [Symbol(Body internals)]: { body: [PassThrough], disturbed: true, error: null },
    [Symbol(Response internals)]: {
      url: 'http://localhost:8888/api/kernels?1677788841157',
      status: 403,
      statusText: 'Forbidden',
      headers: [T [Headers]],
      counter: 0
    }
  },
  traceback: ''
}
error 15:27:21.185: Error fetching remote kernels: [t [Error]: Forbidden
	at t.create (c:\Users\natha\.vscode\extensions\ms-toolsai.jupyter-2023.2.1000592019\out\extension.node.js:2:68927)
	at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
	at async t.listRunning (c:\Users\natha\.vscode\extensions\ms-toolsai.jupyter-2023.2.1000592019\out\extension.node.js:2:56792)
	at async ug.getRunningKernels (c:\Users\natha\.vscode\extensions\ms-toolsai.jupyter-2023.2.1000592019\out\extension.node.js:17:270516)
	at async Promise.all (index 0)
	at async yg.listKernelsFromConnection (c:\Users\natha\.vscode\extensions\ms-toolsai.jupyter-2023.2.1000592019\out\extension.node.js:17:281216)] {
  response: L [Response] {
    size: 0,
    timeout: 0,
    [Symbol(Body internals)]: { body: [PassThrough], disturbed: true, error: null },
    [Symbol(Response internals)]: {
      url: 'http://localhost:8888/api/kernels?1677788841158',
      status: 403,
      statusText: 'Forbidden',
      headers: [T [Headers]],
      counter: 0
    }
  },
  traceback: ''
}
error 15:27:21.192: UniversalRemoteKernelFinder: Failed to get kernels without cache [t [Error]: Forbidden
	at t.create (c:\Users\natha\.vscode\extensions\ms-toolsai.jupyter-2023.2.1000592019\out\extension.node.js:2:68927)
	at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
	at async t.listRunning (c:\Users\natha\.vscode\extensions\ms-toolsai.jupyter-2023.2.1000592019\out\extension.node.js:2:56792)
	at async ug.getRunningKernels (c:\Users\natha\.vscode\extensions\ms-toolsai.jupyter-2023.2.1000592019\out\extension.node.js:17:270516)
	at async Promise.all (index 0)
	at async yg.listKernelsFromConnection (c:\Users\natha\.vscode\extensions\ms-toolsai.jupyter-2023.2.1000592019\out\extension.node.js:17:281216)] {
  response: L [Response] {
    size: 0,
    timeout: 0,
    [Symbol(Body internals)]: { body: [PassThrough], disturbed: true, error: null },
    [Symbol(Response internals)]: {
      url: 'http://localhost:8888/api/kernels?1677788841156',
      status: 403,
      statusText: 'Forbidden',
      headers: [T [Headers]],
      counter: 0
    }
  },
  traceback: ''
}
error 15:27:21.193: SessionManager:getKernelSpecs failure:  [Error: Poll (@jupyterlab/services:KernelSpecManager#specs) is disposed.
	at e.dispose (c:\Users\natha\.vscode\extensions\ms-toolsai.jupyter-2023.2.1000592019\out\extension.node.js:2:172349)
	at u.dispose (c:\Users\natha\.vscode\extensions\ms-toolsai.jupyter-2023.2.1000592019\out\extension.node.js:2:63778)
	at ug.dispose (c:\Users\natha\.vscode\extensions\ms-toolsai.jupyter-2023.2.1000592019\out\extension.node.js:17:269630)
	at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
	at async yg.listKernelsFromConnection (c:\Users\natha\.vscode\extensions\ms-toolsai.jupyter-2023.2.1000592019\out\extension.node.js:17:282013)]
error 15:27:21.194: UniversalRemoteKernelFinder: Failed to get kernels without cache [t [Error]: Forbidden
	at t.create (c:\Users\natha\.vscode\extensions\ms-toolsai.jupyter-2023.2.1000592019\out\extension.node.js:2:68927)
	at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
	at async t.listRunning (c:\Users\natha\.vscode\extensions\ms-toolsai.jupyter-2023.2.1000592019\out\extension.node.js:2:56792)
	at async ug.getRunningKernels (c:\Users\natha\.vscode\extensions\ms-toolsai.jupyter-2023.2.1000592019\out\extension.node.js:17:270516)
	at async Promise.all (index 0)
	at async yg.listKernelsFromConnection (c:\Users\natha\.vscode\extensions\ms-toolsai.jupyter-2023.2.1000592019\out\extension.node.js:17:281216)] {
  response: L [Response] {
    size: 0,
    timeout: 0,
    [Symbol(Body internals)]: { body: [PassThrough], disturbed: true, error: null },
    [Symbol(Response internals)]: {
      url: 'http://localhost:8888/api/kernels?1677788841157',
      status: 403,
      statusText: 'Forbidden',
      headers: [T [Headers]],
      counter: 0
    }
  },
  traceback: ''
}
error 15:27:21.194: SessionManager:getKernelSpecs failure:  [Error: Poll (@jupyterlab/services:KernelSpecManager#specs) is disposed.
	at e.dispose (c:\Users\natha\.vscode\extensions\ms-toolsai.jupyter-2023.2.1000592019\out\extension.node.js:2:172349)
	at u.dispose (c:\Users\natha\.vscode\extensions\ms-toolsai.jupyter-2023.2.1000592019\out\extension.node.js:2:63778)
	at ug.dispose (c:\Users\natha\.vscode\extensions\ms-toolsai.jupyter-2023.2.1000592019\out\extension.node.js:17:269630)
	at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
	at async yg.listKernelsFromConnection (c:\Users\natha\.vscode\extensions\ms-toolsai.jupyter-2023.2.1000592019\out\extension.node.js:17:282013)]
error 15:27:21.195: UniversalRemoteKernelFinder: Failed to get kernels without cache [t [Error]: Forbidden
	at t.create (c:\Users\natha\.vscode\extensions\ms-toolsai.jupyter-2023.2.1000592019\out\extension.node.js:2:68927)
	at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
	at async t.listRunning (c:\Users\natha\.vscode\extensions\ms-toolsai.jupyter-2023.2.1000592019\out\extension.node.js:2:56792)
	at async ug.getRunningKernels (c:\Users\natha\.vscode\extensions\ms-toolsai.jupyter-2023.2.1000592019\out\extension.node.js:17:270516)
	at async Promise.all (index 0)
	at async yg.listKernelsFromConnection (c:\Users\natha\.vscode\extensions\ms-toolsai.jupyter-2023.2.1000592019\out\extension.node.js:17:281216)] {
  response: L [Response] {
    size: 0,
    timeout: 0,
    [Symbol(Body internals)]: { body: [PassThrough], disturbed: true, error: null },
    [Symbol(Response internals)]: {
      url: 'http://localhost:8888/api/kernels?1677788841158',
      status: 403,
      statusText: 'Forbidden',
      headers: [T [Headers]],
      counter: 0
    }
  },
  traceback: ''
}

Coding Language and Runtime Version

No response

Language Extension Version (if applicable)

No response

Anaconda Version (if applicable)

No response

Running Jupyter locally or remotely?

Local

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 2
  • Comments: 16 (7 by maintainers)

Most upvoted comments

It works for me as well, with Jupyter extension version v2023.3.1000892223 (and VS Code v 1.77.0). Thanks for the fix.

This is now working for me with Jupyter extension version v2023.3.1000892223 (and VS Code v 1.77.0)

I followed your suggestion by setting Jupyter logging to verbose, updated Jupyter to v2023.2.1000592019, and reloaded. The kernel just keep spinning. I can’t see the Jupyter output panel as it was just blank (I’m probably not familiar with VSCode/Jupyter and don’t know where to get the output). But it’s just working without problem after going back to v2023.1.2010391206. Sorry that I can’t help much. But thank you for your reply.

I rolled back to jupyter extension v2023.1.2010391206 and everything works fine again.