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

Comments

@gsklee
Copy link

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

This comment has been minimized.

Copy link
Collaborator

commented Jul 5, 2019

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented Jul 5, 2019

Same issue

1 similar comment
@PahmCuogn

This comment has been minimized.

Copy link

commented Jul 5, 2019

Same issue

@waiwaiku

This comment has been minimized.

Copy link

commented Jul 5, 2019

Same issue.

@PaquitoSoft

This comment has been minimized.

Copy link

commented Jul 5, 2019

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

@waiwaiku

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented Jul 5, 2019

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

@Udbhav12

This comment has been minimized.

Copy link

commented Jul 5, 2019

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

@tasosxak

This comment has been minimized.

Copy link

commented Jul 5, 2019

image

I have the same issue.

@LucaMele

This comment has been minimized.

Copy link

commented Jul 5, 2019

issue same here in combination with IE11

@LucaMele

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Member

commented Jul 5, 2019

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

@LucaMele

This comment has been minimized.

Copy link

commented Jul 5, 2019

Is a missing polyfill somewhere in babel runtime.

@JordanProtin

This comment has been minimized.

Copy link

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

@mtr1012

This comment has been minimized.

Copy link

commented Jul 8, 2019

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

@seifsay3d

This comment has been minimized.

Copy link

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?

@mtr1012

This comment has been minimized.

Copy link

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

@belemaire

This comment has been minimized.

Copy link

commented Jul 9, 2019

Just did same code modifications locally as you did in @babel/helpers and it works fine now 👍
Thanks much @nicolo-ribaudo @hzoo

@nicolo-ribaudo

This comment has been minimized.

Copy link
Member

commented Jul 9, 2019

Wohoooo ❤️

@hzoo

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link

commented Jul 9, 2019

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

This comment has been minimized.

Copy link
Member

commented Jul 9, 2019

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

This comment has been minimized.

Copy link

commented Jul 9, 2019

thank you @nicolo-ribaudo

It's working for us

@pwnreza

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Member

commented Jul 9, 2019

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

This comment has been minimized.

Copy link

commented Jul 10, 2019

@nicolo-ribaudo
opened an issue like you suggested
10193

@JordanProtin

This comment has been minimized.

Copy link

commented Jul 10, 2019

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Member

commented Jul 11, 2019

@mikehdt We are tracking it at #10179!

@nicolo-ribaudo

This comment has been minimized.

Copy link
Member

commented Jul 11, 2019

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

@JordanProtin

This comment has been minimized.

Copy link

commented Jul 11, 2019

@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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Member

commented Jul 11, 2019

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented Jul 19, 2019

Hi guys, does anyone fix it?

@nicolo-ribaudo

This comment has been minimized.

Copy link
Member

commented Jul 19, 2019

Yes, v7.5.4

@hoangben

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Member

commented Jul 19, 2019

What's your package-lock.json file?

@AkioUnity

This comment has been minimized.

Copy link

commented Jul 21, 2019

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

This comment has been minimized.

Copy link

commented Jul 22, 2019

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

@hoangben

This comment has been minimized.

Copy link

commented Jul 22, 2019

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

@nicolo-ribaudo

This comment has been minimized.

Copy link
Member

commented Jul 22, 2019

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

This comment has been minimized.

Copy link

commented Jul 24, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.