jupyter / jupyter/notebook

Jupyter notebook run in chrome gets stuck on server restart

Open
#3,764 5 comments 4 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
13.3k
Forks
5.8k
Avg merge
6d 11h
Merged PRs (30d)
7

Description

I start with a working jupyter setup, and everything works just fine. I can interrupt or restart the kernel from the notebook without any problems.

If, however, I change some jupyter configuration, or install some modules, and **restart jupyter server - I have to wait for about 5 minutes for the open notebooks to recover access to the python kernel**.

## To reproduce the problem:

1. Start jupyter (local shell)

jupyter notebook

2. In chrome create a new notebook (python 3), which will result in a url like:

http://localhost:8888/notebooks/Untitled1.ipynb?kernel_name=python3

3. Create and run a single cell in that new notebook:

print(1)

4. Restart jupyter (Ctrl-C followed by [yes] to the prompt to exit), followed by:

jupyter notebook

5. Go to the same chrome tab with the same single cell notebook and click OK for the pop-up `"Connection failed"`

6. Observe the notebook showing: `[Connecting to Kernel]` without success.

7. Try to Restart the kernel via the menu, usually it gets stuck in `[Kernel Starting...]`, and after several manually forced kernel restarts it supposedly succeeds `[Kernel Created]`, but it's a false success, as trying to run the cells gives a `[*]` busy sign and nothing happens.

**After some 5 min of waiting it recovers by itself.**

## Workarounds:

* Reloading the notebook in the browser (i.e. hitting Reload at the browser level)
* Restarting chrome, can add a bookmarklet with chrome://restart/ to make it into 1-click restart.

## Software:

* ubuntu 18.04
* notebook 5.7.4
* python 3.7.1
* chrome 71
* no adblock software enabled
* empty ~/.jupyter (removed everything for the sake of the testing, so no extensions or custom configuration)

Same setup works fine in firefox on the same machine.

There are several tickets on github about the same from 2015 (e.g. https://github.com/jupyter/notebook/issues/1415, but somehow they blame it on chrome and clearly the issue is still there 3 years later).

Any idea how to solve this?

Thank you.

And here is the log during the open notebook reconnect/restart process:

[I 22:54:09.032 NotebookApp] Kernel restarted: 9aa08efb-74b1-471c-ad0f-bb9dc3577c28
[W 22:54:09.343 NotebookApp] Replacing stale connection: 6cc8a446-1dc0-4c01-86ab-f95ae99c24af:10a12a1b834f43298fb9e6f344bc6b26
[W 22:54:45.348 NotebookApp] Replacing stale connection: 6cc8a446-1dc0-4c01-86ab-f95ae99c24af:10a12a1b834f43298fb9e6f344bc6b26
[W 22:55:37.359 NotebookApp] Replacing stale connection: 6cc8a446-1dc0-4c01-86ab-f95ae99c24af:10a12a1b834f43298fb9e6f344bc6b26
[W 22:57:01.367 NotebookApp] Replacing stale connection: 6cc8a446-1dc0-4c01-86ab-f95ae99c24af:10a12a1b834f43298fb9e6f344bc6b26
[I 22:57:41.337 NotebookApp] Adapting to protocol v5.1 for kernel 9aa08efb-74b1-471c-ad0f-bb9dc3577c28
[W 22:57:41.350 NotebookApp] Replacing stale connection: 9aa08efb-74b1-471c-ad0f-bb9dc3577c28:768880fb9a244da99735e983bd6c36c6
[I 22:57:41.351 NotebookApp] Starting buffering for 9aa08efb-74b1-471c-ad0f-bb9dc3577c28:768880fb9a244da99735e983bd6c36c6
[I 22:57:41.351 NotebookApp] Adapting to protocol v5.1 for kernel 9aa08efb-74b1-471c-ad0f-bb9dc3577c28
[I 22:57:41.352 NotebookApp] Restoring connection for 9aa08efb-74b1-471c-ad0f-bb9dc3577c28:768880fb9a244da99735e983bd6c36c6
[I 22:57:49.324 NotebookApp] Starting buffering for 9aa08efb-74b1-471c-ad0f-bb9dc3577c28:768880fb9a244da99735e983bd6c36c6
[I 22:57:49.327 NotebookApp] Adapting to protocol v5.1 for kernel 9aa08efb-74b1-471c-ad0f-bb9dc3577c28
[I 22:57:49.328 NotebookApp] Restoring connection for 9aa08efb-74b1-471c-ad0f-bb9dc3577c28:768880fb9a244da99735e983bd6c36c6

**edit**: updated my setup specs to the current ones.

Contributor guide

Open the contributing guide

Research direction

Reproduce the restart and reconnect sequence with the `jupyter notebook` command in Chrome, while watching the NotebookApp log for stale-connection replacement, buffering, and restoration. Trace the notebook-to-kernel reconnect path and verify that an open notebook reconnects promptly after the server restarts instead of remaining stuck for about five minutes; compare behavior with Firefox as a control.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter-notebook, python
Domain
backend, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.