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

undefined is not a function(evaluation 'object.getOwnPropertyDescriptors(arguments[i])') #10166

Closed
gsklee opened this issue Jul 5, 2019 · 91 comments · Fixed by #10171, #10180 or #10188
Closed
Labels
Has PR i: bug i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue Priority: High

Comments

@gsklee
Copy link

gsklee commented Jul 5, 2019

facebook/react-native#23092

Unfortunately this exact same issue strikes again with the release of Babel v7.5.0.

These are the Babel related dependencies I am having:

    "@babel/core": "7.4.5",
    "@babel/plugin-proposal-class-properties": "7.4.4",
    "@babel/plugin-proposal-decorators": "7.4.4",
    "@babel/plugin-transform-flow-strip-types": "7.4.4",
    "@babel/preset-flow": "7.0.0",
    "babel-eslint": "10.0.2",
    "babel-jest": "24.8.0",
    "metro-react-native-babel-preset": "0.54.1",

With the package-lock.json I generated a few days ago everything's fine with npm install, but if I try to do it without the lockfile the error appears. Judging from my lockfile's diff I can say that a few secondary Babel dependencies were updated to v7.5.0 without the lockfile (eg. @babel/generator, @babel/helper-create-class-features-plugin) so am pretty sure this is a Babel issue again.

@babel-bot
Copy link
Collaborator

Hey @gsklee! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community
that typically always has someone willing to help. You can sign-up here
for an invite.

@edi9999
Copy link

edi9999 commented Jul 5, 2019

I'm confirming the issue is on Babel side, I have the same issue.

To reproduce with an example you can do the following :

git clone https://github.com/open-xml-templating/docxtemplater.git
cd docxtemplater
git checkout fa3d9fed040befaa7d2da7402e0cfbe042564bd4
npm install
# n use 6 (use node 6 which does not have object.getOwnPropertyDescriptors for example)
npm test
# You will have many tests that fail with this error message

I am pretty sure this is the plugin-proposal object-rest-spread since the generated code is as follows :

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { if (i % 2) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } else { Object.defineProperties(target, Object.getOwnPropertyDescriptors(arguments[i])); } } return target; }

This was probably introduced here : #9384

@JordanProtin
Copy link

Same issue

1 similar comment
@PahmCuogn
Copy link

Same issue

@kianfang
Copy link

kianfang commented Jul 5, 2019

Same issue.

@PaquitoSoft
Copy link

We're also having a hard time because of this as well.

@kianfang
Copy link

kianfang commented Jul 5, 2019

resolve.modules: ["node_modules", "web_modules"]

web_modules not work for @bable/core version v7.5.0, import any module from web_modules to invoke will be undefined.

@gorkalaucirica
Copy link

Fixed locking @babel/plugin-proposal-object-rest-spread to 7.4.4in package.json

@Udbhav12
Copy link

Udbhav12 commented Jul 5, 2019

@gorkalaucirica Can you please share your entire package.json here ?

@tasosxak
Copy link

tasosxak commented Jul 5, 2019

image

I have the same issue.

@LucaMele
Copy link

LucaMele commented Jul 5, 2019

issue same here in combination with IE11

@LucaMele
Copy link

LucaMele commented Jul 5, 2019

Is just a missing core js polyfill that needs to be added to babel runtime: import 'core-js/modules/es6.object.get-own-property-descriptor.js';

@JLHwung
Copy link
Contributor

JLHwung commented Jul 5, 2019

A hotfix would be to add the following to your polyfill.js, note that it is different to *get-own-property-descriptor.

import 'core-js/modules/es6.object.get-own-property-descriptors';

Object.getOwnPropertyDescriptors is not supported on Node.js until 7.0.0. As Babel 7 works on Node >= 6.9.0, ideally babel-preset-env should take care of this. I am investigating this issue and hopefully I will work on a fix later.

@nicolo-ribaudo
Copy link
Member

Note that Babel works in node >=6, but it's output should work in older engines

@LucaMele
Copy link

LucaMele commented Jul 5, 2019

Is a missing polyfill somewhere in babel runtime.

@JordanProtin
Copy link

Still I get issue.

my package.json looks like :

"devDependencies": {
    "@babel/core": "7.5.0",
    "@babel/preset-react": "7.0.0",
    "@babel/runtime": "7.5.1",
    "babel-core": "6.26.3",
    "babel-eslint": "10.0.2",
    "babel-jest": "24.8.0",
    "babel-plugin-ignite-ignore-reactotron": "0.3.0",
    "babel-plugin-transform-inline-environment-variables": "0.4.3",
    "babel-preset-env": "1.7.0",
    "babel-preset-react-native": "4.0.1",
   .....

Using react-native v0.57.7

@mtr1012
Copy link

mtr1012 commented Jul 8, 2019

Please fix this issue. Very annoying. Cant fix :(

@seifsay3d-zz
Copy link

Still I get issue.

my package.json looks like :

"devDependencies": {
    "@babel/core": "7.5.0",
    "@babel/preset-react": "7.0.0",
    "@babel/runtime": "7.5.1",
    "babel-core": "6.26.3",
    "babel-eslint": "10.0.2",
    "babel-jest": "24.8.0",
    "babel-plugin-ignite-ignore-reactotron": "0.3.0",
    "babel-plugin-transform-inline-environment-variables": "0.4.3",
    "babel-preset-env": "1.7.0",
    "babel-preset-react-native": "4.0.1",
   .....

Using react-native v0.57.7

Have you tried to update to 7.5.1?

@mtr1012
Copy link

mtr1012 commented Jul 8, 2019

Still I get issue.
my package.json looks like :

"devDependencies": {
    "@babel/core": "7.5.0",
    "@babel/preset-react": "7.0.0",
    "@babel/runtime": "7.5.1",
    "babel-core": "6.26.3",
    "babel-eslint": "10.0.2",
    "babel-jest": "24.8.0",
    "babel-plugin-ignite-ignore-reactotron": "0.3.0",
    "babel-plugin-transform-inline-environment-variables": "0.4.3",
    "babel-preset-env": "1.7.0",
    "babel-preset-react-native": "4.0.1",
   .....

Using react-native v0.57.7

Have you tried to update to 7.5.1?

"@babel/helpers" : "7.5.1",
"@babel/plugin-proposal-object-rest-spread" : "7.5.1",
"@babel/plugin-transform-typescript": "7.5.1"

still the same issue

@hzoo
Copy link
Member

hzoo commented Jul 9, 2019

Great we can make a release very soon then! Thanks for all your patience everyone! We are all learning here (and also I believe Nicolò is studying for exams even).

I think we can do a writeup on some of the issues we've encountered here later as well, and hopefully that's useful to everyone.

  • ES6+ code actually helps fix bugs (...spread instead of arguments)
  • We currently don't use ES6+ in Babel's helpers because we need the helpers themselves to be transpilable (hopefully soon: related to my post but we ideally want ES6+ source in your own app code, your dependencies, and babel's own helpers too)
  • Versioning is hard

@belemaire
Copy link

All good for us, as we had a proper workaround while waiting for a proper fix.
Thanks again for the quick support and your awesome work on Babel.
Looking forward to the new release !
And wish you well for your exams @nicolo-ribaudo ;)

@nicolo-ribaudo
Copy link
Member

Published as 7.5.4!
I have also published @babel/core (even if it didn't contain any change), so that you can update it to be sure that @babel/helpers is ^7.5.4

@pwnreza
Copy link

pwnreza commented Jul 9, 2019

thank you @nicolo-ribaudo

It's working for us

@pwnreza
Copy link

pwnreza commented Jul 9, 2019

@nicolo-ribaudo
We still have a problem and I don't know if it is related to this fix.
There is an often reoccurring pattern in our code regarding redux:

import React, { Component } from 'react';
import { connect } from 'react-redux';
import { someAction } from '../../store/data/actions';

class SomeComponent extends Component {
  componentWillMount() {
    const { someAction } = this.props;
    someAction();
  }

  render() {
    return null;
  }
}

export default connect(null, {
  someAction,
})(SomeComponent);

When I try to "overload" the 'someAction' variable I get an runtime error which I can inspect via logcat (android logs used on my react-native app) looking something like this:

Possible Unhandled Promise Rejection (id: 1): Error: "someAction" is read-only.

If I don't "overload" the variable and instead try to do something like this
componentWillMount() { this.props.someAction(); }
it will work.

I guess it has something to do with how the babel helper handles the arguments and/or the export/imports.
But I am not sure at all.

thanks for your help sofar

@nicolo-ribaudo
Copy link
Member

This seem an unrelated issue.
Can you open a new one posting your Babel config and, if possible, how Babel transpiles that code? You should be able to find it somewhere in the localhost url written in the red screen.

@pwnreza
Copy link

pwnreza commented Jul 10, 2019

@nicolo-ribaudo
opened an issue like you suggested
10193

@JordanProtin
Copy link

Hi guys !
@nicolo-ribaudo Thank you so much !
However, I would like to inform you that I get another issue which comes from redux (I use react-native) : "Property description must be an object" with function _objectSpread2 from nodes_modules/redux.

To solve it, I've to fix redux version to 4.0.0 :
reduxjs/redux#3468 (comment)

Maybe there is a link with babel ? I think, because it's the same issue with declaration of var source = arguments[i] != null ? arguments[i] : {}; inside if condition instead of before.

@mikehdt
Copy link

mikehdt commented Jul 11, 2019

I'm still finding ReferenceError: _objectSpread is not defined is cropping up in 7.5.4 but only when running tests via Jest. My initial suspicion is that it's going to be something in my config that's not working correctly. Will continue to diagnose and if there is anything that I find, happy to update here. Otherwise, assume that I've done something silly 😉

edit: I found it was dying when a second spread existed on the same page. I tried creating a minimal-case reduction and it worked just fine. Huh? So I brought that minimal case back to the same folder as the original repo and it failed, even after removing node_modules and reinstalling. Double huh? Deleted and recreated the yarn.lock file and then it started to behave. Now it's happy.

Leaving this note here in case anyone finds a similar issue remaining, hope it helps.

@nicolo-ribaudo nicolo-ribaudo unpinned this issue Jul 11, 2019
@nicolo-ribaudo
Copy link
Member

nicolo-ribaudo commented Jul 11, 2019

@mikehdt We are tracking it at #10179!

@nicolo-ribaudo
Copy link
Member

@JordanProtin It's because redux updated the Babel version to the buggy one; in 4.0.4 it's fixed.

@JordanProtin
Copy link

@JordanProtin It's because redux updated the Babel version to the buggy one; in 4.0.4 it's fixed.

Thank you for your answer @nicolo-ribaudo

@maxmodel
Copy link

maxmodel commented Jul 11, 2019

Hey @nicolo-ribaudo, thanks again for all your help on this. This issue was resolved for us 2 days ago, and we were able to continue working on our React Native app. However we just pushed our app.aab to the Google Play Store for internal testing, and the app crashes when downloaded from the play store, despite it working fine when running on simulators and devices not through the play store.

It's the original error of "undefined is not a function(evaluation 'Object.getOwnPropertyDescriptors(arguments[i])')". @babel/core and @babel/runtime and @babel/helpers and everything are all at 7.5.4 in our lockfile, and I looked at the lines of code in that /@babel/helpers/lib/helpers.js file that you made changes to in previous PRs, and I can't find any instances of the function supposedly causing the error with arguments[i] as the argument (as I recall you changed that to "source" each time). So it makes sense that I can't find it, but odd that the error finds it.

Any insight on this is appreciated!

@nicolo-ribaudo
Copy link
Member

Maybe for some reason it still used an old version of Babel when building the APK? Maybe there is a "production cache"?

(ALERT: I have never created an android app)
Is it possible to decompile the APK and look at it's JavaScript source code? If it is, then Ctrl+F for Object.getOwnPropertyDescriptors(arguments[i])') and post the surrounding code.

@Luckfried
Copy link

Luckfried commented Jul 15, 2019

this solved the caching problem and after that it used the new version of Babel.

yarn:

watchman watch-del-all &&
rm -rf $TMPDIR/react-native-packager-cache-* &&
rm -rf $TMPDIR/metro-bundler-cache-* &&
rm -rf node_modules/ &&
yarn cache clean &&
yarn install &&
yarn start -- --reset-cache

@hoangben
Copy link

Hi guys, does anyone fix it?

@nicolo-ribaudo
Copy link
Member

Yes, v7.5.4

@hoangben
Copy link

hoangben commented Jul 19, 2019

@nicolo-ribaudo
Like this?

"devDependencies": {
"babel-jest": "24.8.0",
"jest": "24.8.0",
"metro-react-native-babel-preset": "0.55.0",
"react-test-renderer": "16.6.3",
"@babel/runtime": "7.5.4",
"@babel/core": "7.5.4",
"@babel/helpers": "7.5.4"
}

I've changed and run npm install again then react-native run-android but still occur that error :(

@nicolo-ribaudo
Copy link
Member

What's your package-lock.json file?

@AkioUnity
Copy link

I have same issue.

"@babel/core": "^7.5.5",
 "@babel/helpers": "^7.5.5",
 "@babel/runtime": "^7.5.5",
 "metro-react-native-babel-preset": "^0.55.0",
 "babel-eslint": "10.0.2",

@hoangben
Copy link

@nicolo-ribaudo Alright. Thanks a lot. I've to restart my PC and it works ;)

@hoangben
Copy link

@AkioUnity change babel version to 7.5.4 like @nicolo-ribaudo said :)

@nicolo-ribaudo
Copy link
Member

7.5.5 should work too. @AkioUnity Please check in your lockfile that you don't have an older @babel/helpers or @babel/runtime version.

@AkioUnity
Copy link

Yes. it is working fine now.
Thank you @nicolo-ribaudo

@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 23, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Has PR i: bug i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue Priority: High
Projects
None yet