New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 782442 link

Starred by 2 users

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Feature



Sign in to add a comment

HTTP Errors on CORS Fetches end up looking like CORS error

Reported by akh...@dropbox.com, Nov 7 2017

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.75 Safari/537.36

Steps to reproduce the problem:
1. Make a CORS fetch with say <script crossorigin=anonymous>
2. Server is down and 500s or 400s. 
3. The error response does not have CORS access-control-allow-origin headers

What is the expected behavior?
Browser / Dev tools tells you that the resource couldn't be loaded because 400 or 500.

What went wrong?
Dev tools tells / console tells you "Not loading because Access Control Allow Origin header" does not exist.

Did this work before? N/A 

Chrome version: 62.0.3202.75  Channel: n/a
OS Version: OS X 10.12.6
Flash Version: 

This is pretty confusing to developers.

Also, @mkwest told me to file it here and he would be take a look.
 

Comment 1 by kozy@chromium.org, Nov 8 2017

Owner: allada@chromium.org
Status: Assigned (was: Unconfirmed)

Comment 2 by kozy@chromium.org, Nov 8 2017

Cc: allada@chromium.org
Owner: mkwst@chromium.org
Issue said that Mike would be take a look, so assigned to him.

Comment 3 by mkwst@chromium.org, Nov 8 2017

Cc: mkwst@chromium.org
Components: Blink>SecurityFeature>CORS
Owner: tyoshino@chromium.org
tyoshino@: Can you triage this?

Comment 4 by est...@chromium.org, Nov 10 2017

Labels: Hotlist-EnamelAndFriendsFixIt
CORS check can success even when the received response's HTTP status is 4XX or 5XX. The CORS protocol is independent from the rest of the contents of a response.

https://fetch.spec.whatwg.org/#cors-check

Doesn't the console error message you get include something like the following in addition to "No 'Access-Control-Allow-Origin' header is present ..."?

"The response had HTTP status code 400."

This is shown when the status code is equal or greater than 400.

Comment 6 by akh...@dropbox.com, Nov 28 2017

hey! So I don't have time right away to repro locally but here's an example thread https://github.com/github/fetch/issues/301

See the screenshot of the console.

The first line is the HTTP error (the red GET). But the second line has a bunch of goop about CORS. This makes it confusing to developers because the second line has a lot more text and seems like the more important error. I feel like if the load error'ed out as a 400; there is no point in even showing the CORS errors.

Do you agree that this could be confusing to someone who doesn't understand CORS?


I agree with you that CORS is a separate spec but most developers don't care and the current behavior is confusing. This is purely a usability improvement. 
Cc: toyoshim@chromium.org
+toyoshim@

OK. Fair enough. This message could be improved to give the most useful advice to developers. Maybe change of phrase ordering, removal of phrases or change of conditions.
Sounds like a matter of taste?
A server may intentionally returns 400 always just to reject CORS requests, but another may fail to provide an expected A-C-A-O due to server troubles, resulting in 4xx/5xx. So both information will be informative for users, but it depends?

Comment 9 by akh...@dropbox.com, Nov 28 2017

yes. This is totally a matter of taste and I think even cleaning up the CORS errors to say "The server returned a 4xx. The 4xx response also failed the CORS check." which on clicking gives full details of the CORS error will be enough to clarify to developers. Right now, in my experience, most developers get confused.
Labels: -Hotlist-EnamelAndFriendsFixIt
Components: -Blink>SecurityFeature>CORS
Labels: -Type-Bug -Pri-2 Pri-3 Type-Feature
Owner: ----
Status: Untriaged (was: Assigned)
My team doesn't have time to work on this. Sending to DevTools for retriage in case they have some time to work on it.
Components: Blink>SecurityFeature>CORS
Labels: -OS-Mac OOR-CORS
Owner: toyoshim@chromium.org
Status: Assigned (was: Untriaged)
I have a plan to plumb the http status to the DevTool console messages in most cases. I was actually shown in some cases, but temporarily disabled to have consistent behavior between the legacy CORS impl and my new out-of-renderer CORS.

Since I'm taking a leave now, it does not happen soon. If anyone is interested in this, please feel free to take it. But for now, I'd assign myself.
What is the status of this issue?
Owner: ----
OOR-CORS is now under Canary/Dev field study, and will go to Beta.
But at this moment, we haven't made any change for this.

If someone is interested in this, please take the owner.

Probably, we can log the status code as a part of network log in the DevTool, rather than embedding it into the CORS console error message at blink::cors::GetErrorMessage.

In the network log, today, we just say

> GET <url> net::ERR_FAILED

but this could have the status code additionally. The status code is usually stripped in such error case, and needs to be plumbed.
Status: Available (was: Assigned)

Sign in to add a comment