Jupyter Notebook caching issues when developing extensions
- Dominant language
- Jupyter Notebook
- Stars
- 13.3k
- Forks
- 5.8k
- Avg merge
- 6d 11h
- Merged PRs (30d)
- 7
Description
Jupyter notebooks sometimes fail to load when I'm using Safari on macOS. Everything works as expected after loading the page in private mode. Here are my investigations so far.
The javascript console shows the following error.
```
[Error] Unhandled Promise Rejection: TypeError: undefined is not an object (evaluating 'g[e].call')
v (bundle.js:1:516)
65733 (5733.bundle.js:1:617)
v (bundle.js:1:521)
(anonymous function) (bundle.js:1:13309)
(anonymous function) (bundle.js:1:48541)
v (bundle.js:1:521)
(anonymous function) (880.bundle.js:1:401)
(anonymous function) (880.bundle.js:1:10670)
```
I have two cookies when I inspect the "Storage" tab:
```
_xsrf 2|e9205445|66bad0a045b955e88bf95e3ba5861b7f|1702245278 localhost / 1/9/2024, 10:54:38 PM 59 B
username-localhost-8888 "2|1:0|10:1702245278|23:username-localhost-8888|200:eyJ1c2VybmFtZSI6ICI0ODljNjhhMDc0NTk0OTQ4YjMzYWQ2MTNiNzVhYjg5MCIsICJuYW1lIjogIkFub255bW91cyBDaGFsZGVuZSIsICJkaXNwbGF5X25hbWUiOiAiQW5vbnltb3VzIENoYWxkZW5lIiwgImluaXRpYWxzIjogIkFDIiwgImNvbG9yIjogbnVsbH0=|cb271f792498595f6234ddfe0b19efef923a7bf1071a0746f48d07f051ef7e32" localhost / 1/9/2024, 10:54:38 PM 341 B ✓
```
After deleting the two cookies and reloading, I get the usual authentication screen. After entering the token, I'm back to the error above. I also have the following value in local storage.
```
@jupyterlab/services:UserManager#user {"username":"489c68a074594948b33ad613b75ab890","name":"Anonymous Chaldene","display_name":"Anonymous Chaldene","initials":"AC","avatar_url":null,"color":"var(--jp-collaborator-color3)"}
```
When I reload the page in private mode, everything works as expected. The content of cookies and local storage as follows.
```
# Cookies
_xsrf 2|e454d008|601ad77f603c96881bb511faa6a28f88|1702462006 localhost / 1/12/2024, 11:06:46 AM 59 B
username-localhost-8888 "2|1:0|10:1702462006|23:username-localhost-8888|196:eyJ1c2VybmFtZSI6ICI3NGE0YjY5ZTljZjQ0NjY3ODk1NTZhMmQwNDljYTJkZiIsICJuYW1lIjogIkFub255bW91cyBFdXJvcGEiLCAiZGlzcGxheV9uYW1lIjogIkFub255bW91cyBFdXJvcGEiLCAiaW5pdGlhbHMiOiAiQUUiLCAiY29sb3IiOiBudWxsfQ==|ed8d74680b32c3e2bb680d3cb9371cca3007baadfd4cbc09ce3ed6e28cd7cd0c" localhost / 1/12/2024, 11:06:46 AM 337 B ✓
# Local Storage
@jupyterlab/services:UserManager#user {"username":"74a4b69e9cf4466789556a2d049ca2df","name":"Anonymous Europa","display_name":"Anonymous Europa","initials":"AE","avatar_url":null,"color":"var(--jp-collaborator-color1)"}
```
No errors are shown in the console other than a 404 for various icons. I couldn't see an obvious difference between opening in private vs usual mode. Here's the dump when opening in the usual context.
```
[I 2023-12-13 11:11:33.137 ServerApp] Package notebook took 0.0000s to import
[I 2023-12-13 11:11:33.144 ServerApp] Package jupyter_lsp took 0.0069s to import
[W 2023-12-13 11:11:33.145 ServerApp] A `_jupyter_server_extension_points` function was not found in jupyter_lsp. Instead, a `_jupyter_server_extension_paths` function was found and will be used for now. This function name will be deprecated in future releases of Jupyter Server.
[I 2023-12-13 11:11:33.149 ServerApp] Package jupyter_server_terminals took 0.0041s to import
[I 2023-12-13 11:11:33.149 ServerApp] Package jupyterlab took 0.0000s to import
[I 2023-12-13 11:11:33.481 ServerApp] Package jupytext took 0.0661s to import
[I 2023-12-13 11:11:33.481 ServerApp] Package notebook_shim took 0.0000s to import
[W 2023-12-13 11:11:33.481 ServerApp] A `_jupyter_server_extension_points` function was not found in notebook_shim. Instead, a `_jupyter_server_extension_paths` function was found and will be used for now. This function name will be deprecated in future releases of Jupyter Server.
[I 2023-12-13 11:11:33.482 ServerApp] jupyter_lsp | extension was successfully linked.
[I 2023-12-13 11:11:33.484 ServerApp] jupyter_server_terminals | extension was successfully linked.
[I 2023-12-13 11:11:33.486 ServerApp] jupyterlab | extension was successfully linked.
[I 2023-12-13 11:11:33.486 ServerApp] jupytext | extension was successfully linked.
[I 2023-12-13 11:11:33.489 ServerApp] notebook | extension was successfully linked.
[I 2023-12-13 11:11:33.644 ServerApp] notebook_shim | extension was successfully linked.
[I 2023-12-13 11:11:33.660 ServerApp] notebook_shim | extension was successfully loaded.
[I 2023-12-13 11:11:33.662 ServerApp] jupyter_lsp | extension was successfully loaded.
[I 2023-12-13 11:11:33.662 ServerApp] jupyter_server_terminals | extension was successfully loaded.
[I 2023-12-13 11:11:33.664 LabApp] JupyterLab extension loaded from /Users/till/.pyenv/versions/3.10.0/envs/zsmgp/lib/python3.10/site-packages/jupyterlab
[I 2023-12-13 11:11:33.664 LabApp] JupyterLab application directory is /Users/till/.pyenv/versions/3.10.0/envs/zsmgp/share/jupyter/lab
[I 2023-12-13 11:11:33.664 LabApp] Extension Manager is 'pypi'.
[I 2023-12-13 11:11:33.665 ServerApp] jupyterlab | extension was successfully loaded.
[W 2023-12-13 11:11:33.666 ServerApp] [Jupytext Server Extension] Async contents managers like AsyncLargeFileManager are not supported at the moment (https://github.com/mwouts/jupytext/issues/1020). We will derive a contents manager from LargeFileManager instead.
[I 2023-12-13 11:11:33.666 ServerApp] [Jupytext Server Extension] Deriving a JupytextContentsManager from LargeFileManager
[I 2023-12-13 11:11:33.666 ServerApp] jupytext | extension was successfully loaded.
[I 2023-12-13 11:11:33.668 ServerApp] notebook | extension was successfully loaded.
[I 2023-12-13 11:11:33.669 ServerApp] Serving notebooks from local directory: /Users/till/git/zsm
[I 2023-12-13 11:11:33.669 ServerApp] Jupyter Server 2.9.1 is running at:
[I 2023-12-13 11:11:33.669 ServerApp] http://localhost:8888/tree?token=11eb4364ae31779b03d7fe45d040a5ec3e84f72f52598efa
[I 2023-12-13 11:11:33.669 ServerApp] http://127.0.0.1:8888/tree?token=11eb4364ae31779b03d7fe45d040a5ec3e84f72f52598efa
[I 2023-12-13 11:11:33.669 ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 2023-12-13 11:11:33.673 ServerApp]
To access the server, open this file in a browser:
file:///Users/till/Library/Jupyter/runtime/jpserver-16778-open.html
Or copy and paste one of these URLs:
http://localhost:8888/tree?token=11eb4364ae31779b03d7fe45d040a5ec3e84f72f52598efa
http://127.0.0.1:8888/tree?token=11eb4364ae31779b03d7fe45d040a5ec3e84f72f52598efa
[I 2023-12-13 11:11:34.111 ServerApp] Skipped non-installed server(s): bash-language-server, dockerfile-language-server-nodejs, javascript-typescript-langserver, jedi-language-server, julia-language-server, pyright, python-language-server, python-lsp-server, r-languageserver, sql-language-server, texlab, typescript-language-server, unified-language-server, vscode-css-languageserver-bin, vscode-html-languageserver-bin, vscode-json-languageserver-bin, yaml-language-server
```
Here's the dump for opening in private mode.
```
[I 2023-12-13 11:09:48.904 ServerApp] Package notebook took 0.0000s to import
[I 2023-12-13 11:09:48.910 ServerApp] Package jupyter_lsp took 0.0064s to import
[W 2023-12-13 11:09:48.910 ServerApp] A `_jupyter_server_extension_points` function was not found in jupyter_lsp. Instead, a `_jupyter_server_extension_paths` function was found and will be used for now. This function name will be deprecated in future releases of Jupyter Server.
[I 2023-12-13 11:09:48.914 ServerApp] Package jupyter_server_terminals took 0.0039s to import
[I 2023-12-13 11:09:48.915 ServerApp] Package jupyterlab took 0.0000s to import
[I 2023-12-13 11:09:49.324 ServerApp] Package jupytext took 0.0863s to import
[I 2023-12-13 11:09:49.324 ServerApp] Package notebook_shim took 0.0000s to import
[W 2023-12-13 11:09:49.324 ServerApp] A `_jupyter_server_extension_points` function was not found in notebook_shim. Instead, a `_jupyter_server_extension_paths` function was found and will be used for now. This function name will be deprecated in future releases of Jupyter Server.
[I 2023-12-13 11:09:49.324 ServerApp] jupyter_lsp | extension was successfully linked.
[I 2023-12-13 11:09:49.327 ServerApp] jupyter_server_terminals | extension was successfully linked.
[I 2023-12-13 11:09:49.329 ServerApp] jupyterlab | extension was successfully linked.
[I 2023-12-13 11:09:49.329 ServerApp] jupytext | extension was successfully linked.
[I 2023-12-13 11:09:49.332 ServerApp] notebook | extension was successfully linked.
[I 2023-12-13 11:09:49.482 ServerApp] notebook_shim | extension was successfully linked.
[I 2023-12-13 11:09:49.501 ServerApp] notebook_shim | extension was successfully loaded.
[I 2023-12-13 11:09:49.502 ServerApp] jupyter_lsp | extension was successfully loaded.
[I 2023-12-13 11:09:49.503 ServerApp] jupyter_server_terminals | extension was successfully loaded.
[I 2023-12-13 11:09:49.505 LabApp] JupyterLab extension loaded from /Users/till/.pyenv/versions/3.10.0/envs/zsmgp/lib/python3.10/site-packages/jupyterlab
[I 2023-12-13 11:09:49.505 LabApp] JupyterLab application directory is /Users/till/.pyenv/versions/3.10.0/envs/zsmgp/share/jupyter/lab
[I 2023-12-13 11:09:49.506 LabApp] Extension Manager is 'pypi'.
[I 2023-12-13 11:09:49.507 ServerApp] jupyterlab | extension was successfully loaded.
[W 2023-12-13 11:09:49.507 ServerApp] [Jupytext Server Extension] Async contents managers like AsyncLargeFileManager are not supported at the moment (https://github.com/mwouts/jupytext/issues/1020). We will derive a contents manager from LargeFileManager instead.
[I 2023-12-13 11:09:49.507 ServerApp] [Jupytext Server Extension] Deriving a JupytextContentsManager from LargeFileManager
[I 2023-12-13 11:09:49.508 ServerApp] jupytext | extension was successfully loaded.
[I 2023-12-13 11:09:49.510 ServerApp] notebook | extension was successfully loaded.
[I 2023-12-13 11:09:49.511 ServerApp] Serving notebooks from local directory: /Users/till/git/zsm
[I 2023-12-13 11:09:49.511 ServerApp] Jupyter Server 2.9.1 is running at:
[I 2023-12-13 11:09:49.511 ServerApp] http://localhost:8888/tree?token=a08089d6b387a4bb0bdb901b7ccaa12bbe497212576dc4df
[I 2023-12-13 11:09:49.511 ServerApp] http://127.0.0.1:8888/tree?token=a08089d6b387a4bb0bdb901b7ccaa12bbe497212576dc4df
[I 2023-12-13 11:09:49.511 ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 2023-12-13 11:09:49.517 ServerApp]
To access the server, open this file in a browser:
file:///Users/till/Library/Jupyter/runtime/jpserver-16686-open.html
Or copy and paste one of these URLs:
http://localhost:8888/tree?token=a08089d6b387a4bb0bdb901b7ccaa12bbe497212576dc4df
http://127.0.0.1:8888/tree?token=a08089d6b387a4bb0bdb901b7ccaa12bbe497212576dc4df
[I 2023-12-13 11:09:50.382 ServerApp] Skipped non-installed server(s): bash-language-server, dockerfile-language-server-nodejs, javascript-typescript-langserver, jedi-language-server, julia-language-server, pyright, python-language-server, python-lsp-server, r-languageserver, sql-language-server, texlab, typescript-language-server, unified-language-server, vscode-css-languageserver-bin, vscode-html-languageserver-bin, vscode-json-languageserver-bin, yaml-language-server
```
Any ideas what might be going on?
### Runtime
macOS 14.1.2 with Safari 17.1.2 (19616.2.9.11.12).
```bash
$ python --version
Python 3.10.0
$ pip freeze | grep notebook
notebook==7.0.3
notebook_shim==0.2.3
$ pip freeze | grep jupyter
jupyter==1.0.0
jupyter-console==6.6.3
jupyter-events==0.8.0
jupyter-lsp==2.2.0
jupyter_client==8.5.0
jupyter_core==5.4.0
jupyter_server==2.9.1
jupyter_server_terminals==0.4.4
jupyterlab==4.0.7
jupyterlab-pygments==0.2.2
jupyterlab-widgets==3.0.8
jupyterlab_server==2.25.0
```
Contributor guide
Research direction
Reproduce the failure with Safari 17.1.2 in a normal browsing session and compare it with private mode, using the console traces from bundle.js and 5733.bundle.js plus the reported cookies and local-storage entry. Trace the undefined call and determine what condition makes notebook loading fail; done means normal-mode notebook loading works without the reported Promise rejection.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, jupyter-notebook, python
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100