pydata-sphinx-theme icon indicating copy to clipboard operation
pydata-sphinx-theme copied to clipboard

Error: e.map is not a function

Open dstansby opened this issue 1 year ago • 2 comments

I'm trying to get an up to date version of pydata-sphinx-theme working with Matplotlib (https://github.com/matplotlib/matplotlib/pull/27658). With the current main branch of pydata-sphinx-theme search/theme changing/version switching isn't working, and I think this is because of the javascript error we're getting,

Uncaught (in promise) TypeError: e.map is not a function
    g https://output.circle-artifacts.com/output/job/65bed756-88de-4a26-93f0-3d06e9d8950f/artifacts/0/doc/build/html/_static/scripts/pydata-sphinx-theme.js?digest=2f715a4ca1682955a1c0:1
    937 https://output.circle-artifacts.com/output/job/65bed756-88de-4a26-93f0-3d06e9d8950f/artifacts/0/doc/build/html/_static/scripts/pydata-sphinx-theme.js?digest=2f715a4ca1682955a1c0:1
[pydata-sphinx-theme.js:1:4657](https://output.circle-artifacts.com/output/job/65bed756-88de-4a26-93f0-3d06e9d8950f/artifacts/0/doc/build/html/_static/scripts/pydata-sphinx-theme.js?digest=2f715a4ca1682955a1c0)

The code that is triggering this is

const n=(e=e.map((e=>(e.match=e.version==DOCUMENTATION_OPTIONS.theme_switcher_version_match,e.preferred=e.preferred||!1,"name"in e||(e.name=e.version),e)))).map((e=>e.preferred&&e.match)).some(Boolean)

It looks like this is some minified(???) javascript, so I'm not sure how to proceed with debugging. Any pointers welcome (is there a way to turn off the squashing of all the javascript into one line?)

A doc build that has this error is here: https://output.circle-artifacts.com/output/job/65bed756-88de-4a26-93f0-3d06e9d8950f/artifacts/0/doc/build/html/index.html

dstansby avatar Feb 17 '24 10:02 dstansby

Looks like here:

https://github.com/pydata/pydata-sphinx-theme/blob/99f9b1c29854ee0f88884e032acc1997dfae370e/src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js#L386-399

I'm away for the next week or so, so can't be of much help right away, but maybe seeing the unminified version will be enough for you to figure it out without me 🤞

drammock avatar Feb 17 '24 20:02 drammock

This is because the version switcher appears to be trying to load https://output.circle-artifacts.com/_static/switcher.json which is obviously going to not work. Has the option for the version switcher URL changed?

There's an if (data) { around the caller to populateVersionSwitcher, but it appears that's not a sufficient condition?

QuLogic avatar Feb 21 '24 00:02 QuLogic

I tried to recreate this issue, but it seems to work?

From one of the recent builds on matplotlib https://output.circle-artifacts.com/output/job/6954838a-52ab-43ed-8fcc-ddfb47b50117/artifacts/0/doc/build/html/index.html, I can pick a version. It just redirects me to an old build like https://matplotlib.org/3.8.4/

The javascript error is still in the console, but not sure if that's causing the issue.

MridulS avatar Jun 03 '24 17:06 MridulS

Yeah, I think worth closing if noone else can easily reproduce. I can't either, can always re-open if I run across it again.

dstansby avatar Jun 05 '24 16:06 dstansby

I think the original error was fixed by matplotlib/matplotlib#27658, which pointed the switcher to the correct path on CircleCI. If you curl https://output.circle-artifacts.com/_static/switcher.json, then you get {"message":"Route Not Found"}, which is valid JSON, but just not at all in the format expected of the version switcher data.

I'm not sure why there's still a warning in the console, but it appears that it's a different error? It looks like Uncaught (in promise) TypeError: e is null.

QuLogic avatar Jun 05 '24 17:06 QuLogic