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 constructor (evaluating 'new u') #79

Open
Jujenji opened this issue Jun 6, 2018 · 2 comments
Open

undefined is not a constructor (evaluating 'new u') #79

Jujenji opened this issue Jun 6, 2018 · 2 comments

Comments

@Jujenji
Copy link

Jujenji commented Jun 6, 2018

Hey Guys,

Beforehand, im sorry if my Question is obsolete, as it is maybe solved somewhere else on this board, but im quite new to programming and GitHub as well, so i thought ill just ask straight forwardly.

My issue is the following.
Im working in an JS - React Native Scenario where I wanted to create a log decorator for getting indepth logs from my functions (params, call of the function, return values etc.)

My decorator looks like this:

export default function log () {
  return function (target, name, descriptor) {
    const {value} = descriptor;
    descriptor.value = function wrapper (...args) {
      console.log('Function ' + name + ' called with these arguments', args);
      const result = value.call(this, ...args);
      console.log('Function ' + name + ' returned ' + result);
      return result;
    };
    return descriptor;
  };
}

So here is my Issue im facing:

When I test the application with the emulator (running react-native run-android) everything is working fine, the app is functional and I get all the logs I wanted.

As soon as I let it build into a release.apk tho it crashes on start before the Appregistry is even called with the Error Message: undefined is not a constructor (evaluating 'new u')

The legacy decorator is inside the production environment dependencies:

"dependencies": {
    "babel-plugin-transform-decorators-legacy": "^1.3.5",
    "babel-core": "^6",
    "babel-runtime": "^6.0.0",

If there is anything I could provide more to help you guys help me :D just tell me.
Id be very happy if someone could provide some knowledge here.

Thanks a lot.

@loganfsmyth
Copy link
Owner

I don't think there's enough info here to answer this. What new is failing? What makes you think this is an issue with decorators? What are you decorating?

@Jujenji
Copy link
Author

Jujenji commented Jun 7, 2018

Hey logan,
thanks so much for your fast reply.
So the thing is, before implementing the decorator mentioned above everything works smoothly inside the emulator in a Test and in a production environment. Even after implementing and running the app in an test environment, like building a debug version, everything is running smoothly and I get the logs I need and the decorator works as expected. But as soon as I have a compiled version set for release, the app crashes on start with the error message stated.

To answer your questions: I am decorating functions only, as I only want them to be logged. Purposely for example getting to know if my backend calls are called and which params they got, and what their return value is.

For the other question tho, this is what gives me the headache. It literally is "new u" but "u" is not a Class or Object in my Code but is only existing inside the obfuscated Code when compiled and there are like way too many of those.

Is there anything I could provide you or would you have any idea from experience what could cause this?

Thank you and best regards from Germany

J

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

No branches or pull requests

2 participants