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

Android 4.4.4: Uncaught TypeError: Cannot redefine property: then #640

Closed
conechan opened this issue Sep 9, 2019 · 7 comments
Closed

Android 4.4.4: Uncaught TypeError: Cannot redefine property: then #640

conechan opened this issue Sep 9, 2019 · 7 comments
Labels

Comments

@conechan
Copy link

conechan commented Sep 9, 2019

As title, this error throwed in some old Android devices (such as 4.4.4 KTU84P), due to core-js try to redefine the native promise.

    // 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);
    });

I've looked at #615, but seems not the same issue.

@conechan
Copy link
Author

I run Object.getOwnPropertyDescriptor(Promise.prototype, 'then') on the device, it show the descriptor as below.

{
  configurable: false,
  enumerable: true,
  value: function()
  writable: true
}

It seems this error caused by the configurable: false.

@zloirock
Copy link
Owner

Are you sure that it's a native Promise? IIRC it was tested in Android 4.4. It looks like a non-correct polyfill, however, I'm not 100% sure.

@conechan
Copy link
Author

Yes, it's a native Promise. And the browser env is a webview in our app, I am not sure whether it's a regular Android 4.4.4 webview.

I know it's an incorrect behavior :(

Are there any work around to solve this issue? If no, I have to downgrade and lock the core-js version to 3.1.4.

@zloirock
Copy link
Owner

I'll add a workaround.

@zloirock zloirock added the v8 label Sep 10, 2019
@zloirock zloirock changed the title Uncaught TypeError: Cannot redefine property: then Android 4.4.4: Uncaught TypeError: Cannot redefine property: then Sep 10, 2019
@bdwain
Copy link

bdwain commented Sep 16, 2019

thanks for fixing this so quickly @zloirock. Are you planning on releasing the fix anytime soon? I see there's a few unreleased fixes out

@zloirock
Copy link
Owner

Now I haven't enough time for that. Little later.

@ghost
Copy link

ghost commented Sep 23, 2019

Definitely don't want to rush you because I'm sure you're busy, but wanted to just state that this fix would be super helpful in a few spaces I'm in! :) Hope you can release soon.

UberOpenSourceBot pushed a commit to fusionjs/fusionjs that referenced this issue Apr 24, 2020
We're seeing 4521 occurrences in the past month:

```
Error: at emitOne (events.js:121:20): Cannot redefine property: then

stack
at defineProperty (native)
    nativeDefineProperty at /home/udocker/web-payments-experience/node_modules/fusion-cli/node_modules/core-js/modules/es.symbol.js:104:11
    f at /home/udocker/web-payments-experience/node_modules/fusion-cli/node_modules/core-js/internals/hide.js:6:30
    hide at /home/udocker/web-payments-experience/node_modules/fusion-cli/node_modules/core-js/internals/redefine.js:35:7
    redefine at /home/udocker/web-payments-experience/node_modules/fusion-cli/node_modules/core-js/modules/es.promise.js:281:4
    call at /home/udocker/web-payments-experience/webpack/bootstrap:84:21
    Object.push.jWX+ at https://d3i4yxtzktqr9n.cloudfront.net/web-payments-experience/client-legacy-vendor-6fa8dbaec985031d91bc.js:81:61695
    call at /home/udocker/web-payments-experience/webpack/bootstrap:84:21
    Object.push at https://d3i4yxtzktqr9n.cloudfront.net/web-payments-experience/client-legacy-main-5702507d1dcffd2fe721.js:1:1206
    call at /home/udocker/web-payments-experience/webpack/bootstrap:84:21
```

Seems to be caused by zloirock/core-js#640, which affects Android 4.4 devices, which is the minimum support version at Uber.

Upgraded by running the following commands:
```
cd public/fusion-cli/
jazelle upgrade core-js@^3.3.0
```

Co-authored-by: Alexander Smith <[email protected]>
Co-authored-by: Ryan Tsao <[email protected]>
Co-authored-by: Ryan Tsao <[email protected]>
rtsao added a commit to uber-web/jazelle that referenced this issue Nov 12, 2020
https://github.com/uber/fusionjs/pull/723

We're seeing 4521 occurrences in the past month:

```
Error: at emitOne (events.js:121:20): Cannot redefine property: then

stack
at defineProperty (native)
    nativeDefineProperty at /home/udocker/web-payments-experience/node_modules/fusion-cli/node_modules/core-js/modules/es.symbol.js:104:11
    f at /home/udocker/web-payments-experience/node_modules/fusion-cli/node_modules/core-js/internals/hide.js:6:30
    hide at /home/udocker/web-payments-experience/node_modules/fusion-cli/node_modules/core-js/internals/redefine.js:35:7
    redefine at /home/udocker/web-payments-experience/node_modules/fusion-cli/node_modules/core-js/modules/es.promise.js:281:4
    call at /home/udocker/web-payments-experience/webpack/bootstrap:84:21
    Object.push.jWX+ at https://d3i4yxtzktqr9n.cloudfront.net/web-payments-experience/client-legacy-vendor-6fa8dbaec985031d91bc.js:81:61695
    call at /home/udocker/web-payments-experience/webpack/bootstrap:84:21
    Object.push at https://d3i4yxtzktqr9n.cloudfront.net/web-payments-experience/client-legacy-main-5702507d1dcffd2fe721.js:1:1206
    call at /home/udocker/web-payments-experience/webpack/bootstrap:84:21
```

Seems to be caused by zloirock/core-js#640, which affects Android 4.4 devices, which is the minimum support version at Uber.

Upgraded by running the following commands:
```
cd public/fusion-cli/
jazelle upgrade core-js@^3.3.0
```

Co-authored-by: Ryan Tsao <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants