-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ES6 Promise instropection not correctly working #178
Comments
@dendril Having |
I completely agree with you, but doesn't make sense to have a fetch API returning something different from what I can instantiate using a call to the Promise constructor. |
What can I say... If native promise implementation is incorrect - it should be replaced. Most alternative var _fetch = fetch;
window.fetch = (...args) => Promise.resolve(_fetch(...args)); |
Looks nice, but not implementable. Thanks all for take time to answer 😄. |
I had to also wrap the Promise-lookalike returned by .json() in MS Edge (15/16/17), in order to be able to use .finally() on its parsed response: fetch(url)
.then(response => {
let nativeFetchThenable = response.json();
// In MS Edge, fetch().json() returns a non-Promise thenable, which cannot be polyfilled with .finally().
// Therefore, we wrap the thenable by resolving a new (polyfilled) Promise with it,
// so we can call .finally() on the Promise:
let wrappedFetchPromise = Promise.resolve(nativeFetchThenable);
wrappedFetchPromise.then(data => myLocalData = data).finally(() => {
doSomething(myLocalData);
}
);
})
.catch(error => {
myLocalData = [];
console && console.error(error);
}); |
It is correct enough for some applications. |
@Yaffle No-one has shown an example of what is actually not working, so if you have one, it would be more helpful to have an example to discuss. |
@loganfsmyth Yaffle/EventSource#118 |
I added a workaround which should fix a big part of cases by patching |
I'm having this issue also on Microsoft Edge version 44.17763.831.0 and Firefox version 68.12.0esr (32-bit). I'm using 'defaults' for targeting browserlists and the following:
my webpack config is the following:
I'm going crazy |
The following code evaluates to false in
Chrome: Version 49.0.2623.75 (64-bit)
I'm not an expert, but what I can said is, if the environment provides the
fetch API
, we should consider promises available, because any call to fetch() will return a "native" instance instead of a an instance using the polyfill.Make sense?
The text was updated successfully, but these errors were encountered: