New issue
Advanced search Search tips

Issue 753113 link

Starred by 3 users

Issue metadata

Status: WontFix
Owner: ----
Closed: Aug 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 3
Type: Bug



Sign in to add a comment

Fetch throws exception if happens simultaneously with IMG resource

Project Member Reported by lushnikov@chromium.org, Aug 7 2017

Issue description

Chrome Version       : 59.0.3071.115
OS Version: OS X 10.12.6
Other browsers tested:
  Add OK or FAIL after other browsers where you have tested this issue:
     Safari 5: OK

What steps will reproduce the problem?
1. Try to load the following HTML page: (note, img url is exactly the same as fetch url)

<img src="https://source.unsplash.com/240x240/?dog"/>
<script>
(async() => {
  let {status} = await fetch('https://source.unsplash.com/240x240/?dog');
  console.log(status);
})();
</script>

Expected: "200" is in the devtools console
Actual: fetching throws the following error:

Fetch API cannot load https://images.unsplash.com/photo-1489861984294-6a0427175a27?ixlib=rb-0.3.5…ntropy&cs=tinysrgb&w=240&h=240&fit=crop&s=7f5fdc7a0954ccb935424ccff67f361b. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
(index):5 Uncaught (in promise) TypeError: Failed to fetch



This works fine in Safari. If the IMG url is changed in any way, e.g. to request 200x200 image instead of 240x240, no exception is thrown.



 
Labels: Needs-Feedback
What's the url (specifically, origin) of the HTML page?
I serve the demo page under http://localhost:8080 with python's SimpleHTTPServer
Project Member

Comment 3 by sheriffbot@chromium.org, Aug 8 2017

Cc: yhirano@chromium.org
Labels: -Needs-Feedback
Thank you for providing more feedback. Adding requester "yhirano@chromium.org" to the cc list and removing "Needs-Feedback" label.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Status: WontFix (was: Unconfirmed)
This happens because the server adds an access-control-allow-origin header only when the request contains an origin header. Since the response doesn't have Vary: origin, a UA can use a cached response without access-control-allow-origin for a request with origin. 

Closing as WontFix. Please see  issue 718352 .

Comment 5 by kdzwinel@gmail.com, Aug 8 2017

OK, so as far as I understand, this is an issue with the server returning incorrect headers. If <img> loads before fetch, the fetch will fail. What I don't understand is why repeating that fetch multiple times eventually resolves?

https://jsbin.com/nujihir/2/edit?html,output
Screen Shot 2017-08-08 at 13.53.49.png
515 KB View Download
Because the redirect location changes over time, I guess.

Sign in to add a comment