Theia on The LittlestJupyterHub - how to debug?

I am very interested in getting Theia set up on my Littlest JupyterHub installation.

But - I realize I do not understand the install instructions.

Specifically, I have followed all the instructions in that page, for my Ubuntu 20.04 setup, summarized below. All commands via the Terminal offered from the JupyterHub interface drop-down, using Jupyter notebook classic.

# https://github.com/nodesource/distributions#debinstall
curl -fsSL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs
# https://classic.yarnpkg.com/en/docs/install/#debian-stable
sudo npm install --global yarn
# Dependencies for build
sudo apt install -y pkg-config libsecret-1-dev
# https://theia-ide.org/docs/composing_applications
mkdir theia-install
cd theia-install
cat << EOF >> package.json
{
  "private": true,
  "dependencies": {
    "@theia/callhierarchy": "next",
    "@theia/file-search": "next",
    "@theia/git": "next",
    "@theia/markers": "next",
    "@theia/messages": "next",
    "@theia/mini-browser": "next",
    "@theia/navigator": "next",
    "@theia/outline-view": "next",
    "@theia/plugin-ext-vscode": "next",
    "@theia/preferences": "next",
    "@theia/preview": "next",
    "@theia/search-in-workspace": "next",
    "@theia/terminal": "next"
  },
  "devDependencies": {
    "@theia/cli": "next"
  }
}
EOF
sudo yarn
sudo yarn theia build

I have also run:

sudo pip install jupyter-server-proxy

Following @betatim’s recipe, I then ran:

sudo jupyter server extension enable --sys-prefix --py jupyter_server_proxy

I have restarted my JupyterHub, and checked that /home/jupyter-admin/theia-install/node_modules/.bin is, as expected, on the root user’s PATH.

My confusion now is - how do I debug my installation? Can y’all point me to somewhere I can start?

Many thanks for any help.

Just as an extra point of debugging:

sudo yarn theia start --hostname 0.0.0.0 -p 3000

does work in giving me the Theia editor available on port 3000. So I think Theia is installed correctly, it is just I am not configuring the jupyter-theia-proxy correctly. But I am still stuck as to where to go next to test / debug.

Have you tried testing jupyter-server-proxy on its own, e.g. by connecting to an existing web service?
https://jupyter-server-proxy.readthedocs.io/en/latest/arbitrary-ports-hosts.html

In case you weren’t aware jupyter-server-proxy isn’t secure when run on a multi-user system since any user on that system can by default connect to the backend services, it’s usually recommended to provide network segregation by running the single-user server in a container.

1 Like

Thanks for this - yes, that check works. For example, running:

python -m http.server 3020

and then going to https://<my-hub-url>/user-redirect/proxy/3020 gives me a file listing, as expected.

Is there a straightforward way to debug the Theia proxy, specifically?

1 Like

Most jupyter-server-proxy extensions are fairly straight-forward and just proxy the backend service straight through. You could try turning on debug logging for JupyterLab since the jupyter-server-proxy logs should go there.

Is there any way to get some debug logs out of Theia?

Finally can you open your browser’s web/javascript console and see if there are any messages?

Largely because of your (@manics ) warning, I decided to switch to Docker containers, for use with a JupyterHub Kubernetes setup.

I have got further, but now I am stalled. I had to run Theia via a wrapper :

Latest container is matthewbrett/nipraxis-hub:e2dcf0a.

When I start up my Docker container, forwarding the standard port, along with 3020:

docker run -ti --rm -p 8888:8888 -p 3020:3020 matthewbrett/nipraxis-hub:e2dcf0a

I do indeed get a ‘Theia’ option in the JupyterLab interface. When I click on it, I get the URL http://127.0.0.1:8888/theia. The page starts with Theia’s revolving circle, but stalls there.

The command being run by jupyter_theia_proxy appears to be:

['theia', 'start', '.', '--hostname 127.0.0.1', '--port=' + str(port)]

If instead, I start a terminal in the JupyterLab interface, and run this:

theia start . --hostname 0.0.0.0 --port 3020

Then sure enough, localhost:3020 does give me a working Theia interface.

I’ve tried replacing --hostname 0.0.0.0 into the jupyter_theia_proxy command, with no benefit.

So, for some reason, the jupyter-server-proxy version of the command seems to be hanging …

  • Is there any reason why the proxying version of the command would hang, when apparently the same command does not, from the terminal?
  • The install instructions for Theia seem to make it impossible to start with a simple theia command, hence my wrapper. Should the wrapper be part of jupyter_theia_proxy?

It’s possible that jupyter-server-proxy is setting some headers that Theia doesn’t understand, e.g. see absolute* in Starting & Proxying processes — Jupyter Server Proxy documentation or Accessing Arbitrary Ports or Hosts — Jupyter Server Proxy documentation

Can you open your browser’s web/javascript console and see if there are any messages?

You can open a GitHub bug report, maybe Theia has changed since the extension and instructions were written? I can’t guarantee someone will have time to investigate further though, so you may be the best person to investigate it.

Another alternative is to look at GitHub - betatim/vscode-binder: VS Code on Binder which definitely works on mybinder

Hmm - thanks! Indeed, messages to the console of form:

[W 2022-03-08 19:14:26.490 ServerApp] 404 GET /socket.io?EIO=4&transport=polling&t=Nzgz40B (172.17.0.1) 1.73ms referer=http://127.0.0.1:8888/theia/
[I 2022-03-08 19:14:28.601 ServerApp] 302 GET /socket.io/?EIO=4&transport=polling&t=Nzgz4Xp (172.17.0.1) 0.55ms
[W 2022-03-08 19:14:28.608 ServerApp] 404 GET /socket.io?EIO=4&transport=polling&t=Nzgz4Xp (172.17.0.1) 1.54ms referer=http://127.0.0.1:8888/theia/

I have a strong wish to get Theia working, if at all possible, to avoid the in-practice vendor lock-in of VSCode.

I’ve raised an issue with Jupyter-Proxy-Server at Theia proxy hangs, where Thiea on own port works correctly · Issue #332 · jupyterhub/jupyter-server-proxy · GitHub

Did you try theabsolute* options mentioned in my previous post? Does that change the browser console messages?

Thanks for following up.

I tried absolute_url=True, just now - https://github.com/matthew-brett/jupyter-server-proxy/tree/theia-futz

I get this error instead:

[W 2022-03-09 23:42:02.903 ServerApp] 404 GET /theia/ (172.17.0.1) 2631.98ms referer=[http://127.0.0.1:8890/lab](http://127.0.0.1:8890/lab)

The error is the same for the default hostname encoded in the theia command:

['theia', 'start', '.', '--hostname=127.0.0.1', '--port=' + str(port)]

or with:


['theia', 'start', '.', '--hostname=0.0.0.0', '--port=' + str(port)]

Was there some other absolute* option to try? That’s the only one I saw.

To follow up, for posterity - after many dangers, toils and trials, I got Theia working through a HTTPS-encrypted JupyterHub / Kubernetes setup - see Theia proxy hangs, where Thiea on own port works correctly · Issue #332 · jupyterhub/jupyter-server-proxy · GitHub

2 Likes