executablebooks / thebe

Turn static HTML pages into live documents with Jupyter kernels.
https://thebe.readthedocs.io
BSD 3-Clause "New" or "Revised" License
386 stars 68 forks source link

Try and detect CORS errors and report them to users #754

Open agoose77 opened 3 weeks ago

agoose77 commented 3 weeks ago

Context

We saw a misconfigured Binder instance that had problems with CORS, but it wasn't visible from the UI that it was CORS at fault! I wonder if we can see this and surface it to the users.

Proposal

No response

Tasks and updates

No response

stevejpurves commented 3 weeks ago

any idea on how to reproduce that easily @agoose77?

agoose77 commented 3 weeks ago

The check that I used was to spin up a trivial event source, and look for CORS errors in the browser console. Here's an example for the Pythia cookbook that, at the time, was failing to launch

const es = new EventSource("https://binder.projectpythia.org/build/gh/ProjectPythia/HRRR-AWS-cookbook/HEAD") 
es.close()

I'm not sure if it's trivial to programatically detect the CORS issue, now that I think about it. I'm not sure if the EventSource actually exposes this information. Maybe the best we can do is: