Version: 52
OS: Linux
I'm just picking on the fetch API for ease-of-access but this looks like a more widespread spec compliance issue. Certain APIs are specced as "throw a <Exception>" but appear to be implemented as "reject <promise> with a <Exception>". I could be misinterpreting the spec. Both Chrome and Firefox exhibit this non-spec-compliant behaviour.
What steps will reproduce the problem?
fetch('http://%zz').then(x => console.log('success:', x), y => console.log('error:', y));
What is the expected output?
A TypeError is thrown.
What do you see instead?
Console:
error: TypeError: Failed to execute 'fetch' on 'Window': Failed to parse URL from http://%zz(…)
Additional info:
See https://fetch.spec.whatwg.org/#fetch-api §6.3 Request(input, init) constructor, Step 12.2:
"If parsedURL is failure, throw a TypeError."
It doesn't say to reject the promise, nor can I find anything in the Web IDL spec that says "throw an Exception" can be interpreted as "reject a promise".
More concerning, I found that TypeErrors generated automatically by the IDL bindings code in Chrome will reject the promise if there is a promise result. The Web IDL spec says to throw TypeErrors, not reject promises.
Could someone comment on whether this is an implementation bug, a spec problem, or whether I am just misinterpreting (if the latter, please point me to where the spec agrees with the implementation).
Comment 1 by yhirano@chromium.org
, Apr 13 2016