Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jupyter Notebook caching issues when developing extensions #7182

Open
tillahoffmann opened this issue Dec 13, 2023 · 13 comments
Open

Jupyter Notebook caching issues when developing extensions #7182

tillahoffmann opened this issue Dec 13, 2023 · 13 comments
Labels

Comments

@tillahoffmann
Copy link

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).

$ 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
@tillahoffmann tillahoffmann added bug status:Needs Triage Applied to issues that need triage labels Dec 13, 2023
@jtpio
Copy link
Member

jtpio commented Dec 13, 2023

Thanks @tillahoffmann for the report.

Curious if this is also the case with JupyterLab?

@tillahoffmann
Copy link
Author

Interestingly, JupyterLab seems to work just fine.

@jtpio
Copy link
Member

jtpio commented Dec 13, 2023

This looks a little bit similar to #6952, but not sure it's exactly the same issue.

Does this error show up in JupyterLab as well?

[Error] Unhandled Promise Rejection: TypeError: undefined is not an object (evaluating 'g[e].call')

@tillahoffmann
Copy link
Author

The javascript console doesn't show any errors when using JupyterLab.

@JasonWeill
Copy link
Collaborator

@tillahoffmann Do you have any content blocking extensions, like ad blockers, running in Safari? Extensions may not run in private mode. If you disable extensions in regular mode in Safari, do you still see this problem?

@tillahoffmann
Copy link
Author

tillahoffmann commented Dec 21, 2023

I have Tampermonkey, Adblock Plus, and Userscripts installed. The issue persists when they are turned off.

I've dug in a bit further, and it seems to be related to caching of resources. When I open developer tools in standard mode rather than private, select the "Network" tab in the developer tools, select "Disable Caches", and refresh, things work again. This seems to fix things for a while. I haven't quite figured out what makes it break again.

Maybe I have different versions of Jupyter in different virtualenvs that could break things? Say I have version x that is cached by Safari but I try to run a notebook with version y. I haven't been able to reproduce that yet, however. Say that was the issue, which of the jupyter packages could be a possible culprit (I'll keep an eye on the versions of those packages)?

@RRosio
Copy link
Collaborator

RRosio commented Jan 2, 2024

Thank you for investigating this issue @tillahoffmann. It seems like when developing Jupyter you might need to disable the cache to avoid this problem.

A comment by @krassowski in the Triage meeting something to further investigate would be if we are doing all we can to avoid this issue in Notebook, via cache busting query parameter for Notebook resources.

@JasonWeill JasonWeill removed status:Needs Info status:Needs Triage Applied to issues that need triage labels Jan 9, 2024
@ericsnekbytes ericsnekbytes changed the title Jupyter Notebook fails to load in Safari but works in private mode. Jupyter Notebook caching issues when developing extensions Jan 9, 2024
@bobpepin
Copy link

bobpepin commented Jan 9, 2024

I have the same issue after upgrading Jupyter, so this also affects users

@jsdodge
Copy link

jsdodge commented Jan 11, 2024

Having the same problem! Safari Version 17.1.2 (19616.2.9.11.12), MacOS 14.1.2 (23B92)

@paschembri
Copy link

Same issue. Workaround : clear cache.

Env:

  • Safari Version 16.5.2 (18615.2.9.11.10)
  • IPython : 8.20.0
  • ipykernel : 6.28.0
  • ipywidgets : 8.1.1
  • jupyter_client : 8.6.0
  • jupyter_core : 5.7.1
  • jupyter_server : 2.12.2
  • jupyterlab : 4.0.10
  • nbclient : 0.9.0
  • nbconvert : 7.14.0
  • nbformat : 5.9.2
  • notebook : 7.0.6
  • qtconsole : 5.5.1
  • traitlets : 5.14.1

@jybantang
Copy link

Thank you very much!

The solution of paschembri is confirmed. The following worked after having cleared the cache only for localhost.

Safari > Settings > Privacy > Manage Website Data > [search: localhost] > [choose "localhost"] > [click "Remove All"]

Original symptoms:

  • Works with "Private Window".
  • Works with other browser clients.

Safari Version 17.3.1 (19617.2.4.11.12)
macOS Sonoma 14.3.1 (23D60)

@vivek-rd
Copy link

Thank you @paschembri ! Clearing cache worked.

@taozhiyuai
Copy link

works on safari.thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants