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

Static resources fail to load in Notebook renderer with 401 error #175033

Closed
DonJayamanne opened this issue Feb 21, 2023 · 11 comments · Fixed by #182664 or microsoft/vscode-jupyter#13531
Closed
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders notebook-api verified Verification succeeded
Milestone

Comments

@DonJayamanne
Copy link
Contributor

Originally filed here microsoft/vscode-jupyter#12843

Problem:

  • Notebook kernel pre-load scripts are now defined statically via the package.json contribution notebookPreload
  • However VS Code throws a 401 error when loading resources from within the Jupyter extension,

If however we have a dummy script file (in the Jupyter extension directory) that is defined as a rendererScripts in the createNotebookController VS Code API , then all resources from Jupyter extension directory are loaded

I.e. using the above API in some way registers the Juptyer extension directory as a supported root for scripts, and using the static contribution ntoebookPreload does not.

@DonJayamanne
Copy link
Contributor Author

@mjbvz I have a work around in the Jupyter extension right now, i've added a dummy placeholder script that does nothing,

@DonJayamanne DonJayamanne changed the title Resources fail to load in Notebook renderer with 401 error Static resources fail to load in Notebook renderer with 401 error Feb 21, 2023
@mjbvz
Copy link
Collaborator

mjbvz commented Feb 22, 2023

@DonJayamanne Can you share steps to reproduce this with the fix in place? Also, does this happen on normal desktop too, or only sshe

Unclear why this is not working as we should add preloads to the local resource roots:

Array.from(this.notebookService.getStaticPreloads(this.notebookViewType), x => dirname(x.entrypoint)),

@DonJayamanne
Copy link
Contributor Author

DonJayamanne commented Feb 22, 2023

@mjbvz
Here are the steps

  • Install Python
  • Install VS Code insiders and latest pre-release versions of Jupyter and Python
  • NOTE: Install the pre-release version of Jupyter extension that is 2 days old
  • Add the following setting into vscode
	"jupyter.widgetScriptSources": [
	],
  • Create a python env and install the following dependencies
    You can use the command python -m venv .venv to create a .venv directory with Pytohn in a particular workspace folder (optionally you can use Python extension to do this for you)
python -m pip install ipykernel ipywidgets ipympl matplotlib
  • Run the following code in a notebook pointing to the above venv (i.e. select the above venv as a kernel)
%matplotlib widget
import matplotlib.pyplot as plt
import numpy as np

X = np.linspace(0, 2*np.pi)
Y = np.sin(X)

fig, ax = plt.subplots()
ax.plot(X, Y)
  • You might get prompted to enable CDN download, hit cancel for that
  • The widget will not load, network tab in vscode will display a 401 error

Note: This is now working in the latest pre-release version of Jupyter extension

@mjbvz
Copy link
Collaborator

mjbvz commented Mar 7, 2023

I believe the broken version is be v2023.2.1000451018 but I'm having trouble reproducing this

@DonJayamanne The output either never renders anything (but there is no network error) or renders as an image:

Screenshot 2023-03-06 at 4 59 28 PM

Screenshot 2023-03-06 at 4 57 19 PM

Any other steps?

@mjbvz mjbvz added bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster labels Mar 7, 2023
@DonJayamanne
Copy link
Contributor Author

DonJayamanne commented Mar 14, 2023

Not sure which pre-release to use anymore, as the pre-release has changed since

	"jupyter.widgetScriptSources": [
	],
  • Create a python env and install the following dependencies
    You can use the command python -m venv .venv to create a .venv directory with Pytohn in a particular workspace folder (optionally you can use Python extension to do this for you)
python -m pip install ipykernel ipywidgets ipympl matplotlib
  • Run the following code in a notebook pointing to the above venv (i.e. select the above venv as a kernel)
%matplotlib widget
import matplotlib.pyplot as plt
import numpy as np

X = np.linspace(0, 2*np.pi)
Y = np.sin(X)

fig, ax = plt.subplots()
ax.plot(X, Y)
  • You might get prompted to enable CDN download, hit cancel for that
  • The widget will not load, network tab in vscode will display a 401 error

Screenshot 2023-03-14 at 11 01 16

@mjbvz mjbvz modified the milestones: March 2023, April 2023 Mar 20, 2023
@mjbvz mjbvz removed the info-needed Issue requires more information from poster label Mar 20, 2023
@mjbvz
Copy link
Collaborator

mjbvz commented Apr 4, 2023

I'm still unable to reproduce this issue

@DonJayamanne Are you running the jupyter out of sources by chance or have you patched VS Code/jupyter in some other way? The path to the resource we a trying to load looks weird: ~/Desktop/development/vcs/vscode-jupyter/..... This looks like an extension development path

In normal installs, we should load resources from a path that looks more like:

~/.vscode-insiders/extensions/ms-toolsai.jupyter-renderers-1.0.15/..

If you are able, you can also try setting a breakpoint in _getResourceRootsCache and sharing the result of that function compared to the path of the js file we try loading in the webview

@mjbvz mjbvz added the info-needed Issue requires more information from poster label Apr 18, 2023
@mjbvz mjbvz modified the milestones: April 2023, May 2023 Apr 24, 2023
@vscodenpa
Copy link

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

@vscodenpa vscodenpa closed this as not planned Won't fix, can't repro, duplicate, stale May 2, 2023
@DonJayamanne DonJayamanne reopened this May 2, 2023
@DonJayamanne
Copy link
Contributor Author

DonJayamanne commented May 2, 2023

information was provided

@DonJayamanne DonJayamanne removed the info-needed Issue requires more information from poster label May 2, 2023
mjbvz added a commit to mjbvz/vscode that referenced this issue May 16, 2023
@vscodenpa vscodenpa added unreleased Patch has not yet been released in VS Code Insiders insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels May 16, 2023
@mjbvz
Copy link
Collaborator

mjbvz commented May 18, 2023

@DonJayamanne #182664 lets you specific an additional set of localResourceRoots that should be allowed when loading the preload. Can you please try adding these for the python static preload contribution? Let me know if fixes the problem!

@DonJayamanne
Copy link
Contributor Author

Thanks @mjbvz , seems to work, microsoft/vscode-jupyter#13531

@DonJayamanne
Copy link
Contributor Author

Changes were made upstream in VS Code, marking as verified.

@DonJayamanne DonJayamanne added the verified Verification succeeded label May 31, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jun 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders notebook-api verified Verification succeeded
Projects
None yet
3 participants