No way to prevent Chrome from putting error in console for non-2xx fetch
Reported by
rekt...@gmail.com,
Dec 30 2016
|
||
Issue description
UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2950.4 Safari/537.36
Steps to reproduce the problem:
1. open console from any given web page
2. catch all errors by typing: window.onerror= function(e){ e.preventDefault() }
3. fetch a 404 resource by typing: fetch("http://google.com/nopenopenope", {mode: "no-cors"})
What is the expected behavior?
The expected behavior, according to whatwg, is a promise which eventually resolves. This happens.
What went wrong?
Chrome, in addition to providing the official spec response, puts an error message into console, in a totally unspecified way, with zero way to prevent this from happening. This prevents fetch &al from being used to speculatively look for resources without highly polluting the console, which no spec suggests it should do. If Chrome wants to log fetch errors to console in an out of spec fashion, it should respectfully offer a means for fetch users to request this additional behavior not be done.
I don't have a strong opinion on how or what that opt-out would look like. Adding a window.onerror handler that tries to swallow window errors seemed like a sensible sane approach to swallowing this error you are throwing to the window. Alternatively, if Chrome doesn't want to hook into standard well defined mechanisms to disable the completely above-and-beyond unspecified behavior it's engaging in, perhaps adding an optional parameter to fetch() could be good? fetch("hhtp://google.com/nopenopenope", {mode: "no-cors", logError: false}); for example could be an optional way to tell Chrome not to log a speculative fetch as an error.
Did this work before? No
Chrome version: 57.0.2950.4 Channel: dev
OS Version:
Flash Version: Shockwave Flash 24.0 r0
I filed a ticket with fetch spec in hopes of creating some concensus for how to issue hints to tell Chrome not to do it's normal, super aggressive, completely unspecified practice of logging non-2xx responses as errors, even if the developer expects the request to fail but wants to try anyway. The high ranking spec gods shot it down pretty fast as being not related to the current fetch spec.
https://github.com/whatwg/fetch/issues/428
I strongly feel that Chrome needs to provide some way for JS authors to indicate that they do not wish for Chrome to engage in this unspecified, scary behavior when they go to speculatively fetch resources that they know may or may not exist.
,
Dec 1 2017
|
||
►
Sign in to add a comment |
||
Comment 1 by pfeldman@chromium.org
, Jan 3 2017Status: Assigned (was: Unconfirmed)