Skip to content
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

Since 3.2.0: Promise.then stopped working on old devices #615

Closed
fdc-viktor-luft opened this issue Aug 12, 2019 · 7 comments
Closed

Since 3.2.0: Promise.then stopped working on old devices #615

fdc-viktor-luft opened this issue Aug 12, 2019 · 7 comments

Comments

@fdc-viktor-luft
Copy link

I want to report a bug which is related to the release of version 3.2.0.

It works on 3.1.4 perfectly and I found the piece of code that breaks the application which has to run on Andoird 2.x devices.

What happened:

Promise.then stopped working. The provided callbacks do not execute at all.

How I fixed it:

In the file es.promise.js I commented out lines 278 - 286, which is currently:

nativeThen = NativePromise.prototype.then;

// wrap native Promise#then for native async functions
redefine(NativePromise.prototype, 'then', function then(onFulfilled, onRejected) {
  var that = this;
  return new PromiseConstructor(function (resolve, reject) {
    nativeThen.call(that, resolve, reject);
  }).then(onFulfilled, onRejected);
});

Then everything worked again on Adnoird 2.x. Since I don't know what this peace of code was intended to achieve, I didn't upload a pull request myself.

Please find some expert to fix that issue. I would be glad to help by testing whatever changes on the Andoird 2.x devices.

@zloirock
Copy link
Owner

It's a patch for a native Promise when it's available but incorrect, however, used by some APIs like async functions, see #579. Android 2.x haven't native promises, so it can be a conflict with another polyfill. Could you add a reproducible example?

@fdc-viktor-luft
Copy link
Author

I'm polyfilling only via core-js.

Since it highly depends on the used browser, I don't know how to build something to reproduce it. Maybe you have access to some EInk-Reader based on old Android version (like the Tolino Shine 1 - sold in Germany).

What I've tested then was:

import 'core-js/es';

new Promise(resolve => {
    // promise resolves in 2 seconds
    setTimeout(resolve, 2000);
}).then(() => {
    // this function get's never executed
    window.alert('foo');
});

@zloirock
Copy link
Owner

Without another global Promise, this issue is impossible. At least, please, add a stack trace.

@zloirock
Copy link
Owner

Theoretically, it can be caused by recursion in promise, used in the microtask implementation, but the reason could be only in the conflict with another polyfill. I'll add a workaround, could you test it?

@fdc-viktor-luft
Copy link
Author

Of course I would test it 👍

@fdc-viktor-luft
Copy link
Author

Ok. I don't know why exactly, but that fixed it 😁 Thanks for your fast fix. When can I expect to download the next version with that fix?

@zloirock
Copy link
Owner

Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants