question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Potential Chrome CORS problem with local output

See original GitHub issue

cc @jakirkham @canavandl @martey

Under certain circumstances, loading local HTML Bokeh output can result in the error:

Access to script at ‘https://cdn.bokeh.org/bokeh/release/bokeh-2.0.0.min.js’ from origin ‘null’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

The circumstance is this: BokehJS was previously first loaded from CDN without SRI/crossorigin attributes on the script tag, and then subsequently later, was loaded with them present. Evidently Chrome uses the cached headers and decides there is a mismatch. Steps to repro:

  • clear cached images and files in chrome
  • open a private window
  • navigate to iris example in docs gallery
  • run iris.py and open local iris.html file in a browser

When can this happen? For one, CDN loads in autoload_static were not fixed up in the last release, and still use “bare” script tags. So I think anyone who views our garllery first, then output_file output, will run in to this.

  • A force-reload will fix and allow things to work (but a bad UX)
  • Have not yet tested to see if other browsers are affected (but I don’t think so)

Certainly, we should fix up autoload_static ASAP so that gallery viewing does not instigate this for users. Should be easy and can go in a 2.0.1 next week.

But user generated output could also instigate this for viewers if the users use “bare” script tags in their Flask app or whatever. We don’t really have control over that.

Is there another fix or mitigation we can apply to make sure it always works, regardless? Would adding an crossorigin="anonymous" even to script tags without SRI hashes fix this? (I will try to test out later).

Thoughts welcome.

Some references:

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:29 (19 by maintainers)

github_iconTop GitHub Comments

5reactions
bryevdvcommented, Apr 11, 2020

@hmanuel1 This means at some point your browser has first loaded BokehJS resources from CDN without the SRI hashes specified, then later tried to load them with the hashes specified. I don’t know where or how this happened for you. AFAIK all the docs have now been updated to always specify the hashes, but it’s possible there might be something in the docs (or an example) that was missed and that generated output without the hashes that you then viewed. There’s nothing for anyone to do except for you to force-reload the page (once). [1] Otherwise if you ever happed to notice a page that loads BokehJS >= 2.0.1 without specifying the integrity attribute on the script tag, please point it out to use so we can change it.

[1] Many people think Chrome’s SRI policy wrt cached scripts in this instance is bad/incorrect. Perhaps Chrome will change some day.

0reactions
bryevdvcommented, Mar 15, 2021

@UlyssesInvictus @martey Thank you for you comments. The only reliable process that was ever discovered to repro this involved cached files and exactly matched the details of other Chrome issue I linked much earlier. Accordingly, I don’t actually think any AWS-side changes can resolve this, except perhaps not allowing caching at all, and that is too costly for us. In retrospect, this conclusion probably should have occurred to me earlier.

Now, it seems there may be other ways to trigger a CORS problem but there has never been any reliable way to repro them. Which means the cycle time to just “try something and see if there are still user reports” can stretch into months or years (we are already at that point!) out to “forever”.

Given the especially egregious “blank page” failure mode, that is just not acceptable, unfortunately. I think the decision to remove the SRI hashes in output the library generates should stand.

Read more comments on GitHub >

github_iconTop Results From Across the Web

3 Ways to Fix the CORS Error — and How the Access-Control ...
Fix one: install the Allow-Control-Allow-Origin plugin. The quickest fix you can make is to install the moesif CORS extension .
Read more >
Private CORS requests failing in some situations due to PNA ...
"Block insecure private network requests." The new error message is "Access to script at 'http://192.168.1.168:8888/js/jquery.min.js' from ...
Read more >
CORS error on request to localhost dev server from remote site
I encountered this error message in the Chrome dev-tools console for all my assets: Access to CSS stylesheet at 'http://localhost:8080/build/app ...
Read more >
I started getting CORS errors after upgrading to v76.
The requests are going from my local computer to an internal URL. This had been working fine up ... Since upgrading to v76,...
Read more >
Troubleshoot CORS errors from API Gateway - Amazon AWS
Resolution · Confirm the cause of the error · Configure CORS on your API resource that's experiencing the error · Configure your REST...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found