Skip to content

Incorrect name of async function after build. #5663

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

Closed
zhengxiaoyao0716 opened this issue Nov 1, 2018 · 5 comments
Closed

Incorrect name of async function after build. #5663

zhengxiaoyao0716 opened this issue Nov 1, 2018 · 5 comments
Labels

Comments

@zhengxiaoyao0716
Copy link

Is this a bug report?

Yes

Did you try recovering your dependencies?

I generated a new project to test it.

Environment

While, the command create-react-app --info seems not work...
(paste the output of the command here)
image

So let me paste my package.json instead (just create a new project use npx create-react-app):

{
  "name": "test",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^16.6.0",
    "react-dom": "^16.6.0",
    "react-scripts": "2.1.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ]
}

Steps to Reproduce

  1. remove all the useless asset, we only need an index.js to reproduce it.
  2. paste those code into index.js:
const test = {
    fn0: () => { },
    fn1: function () { },
    fn2() { },

    fn3: async () => { },
    fn4: async function () { },
    async fn5() { },

    fn6: () => Promise.resolve(),
};
console.log(Object.entries(test).map(([key, func]) => ({ key, name: func.name, func })));

image

  1. Now start the project, at the development environment (npm run start), what the browser terminal print:
    image
    seems all right.
  2. However, if we start the project with production mode (npm run build), the problem appeared:
    image

Maybe this problem is a bug of webpack, but due to the create-react-app not allow us to build the project in development mode, or build without minify, I found hard to further locate the problem .

@zhengxiaoyao0716
Copy link
Author

The problem also happend with static function of class, neither async or normal:

class Test {
    static fn() {}
}
console.log(Test.fn.name);

It always print value.

@zhengxiaoyao0716
Copy link
Author

I found that after build it would generate some codes like {fn:function(){},async:function(){function t(){};return t}()} , so maybe the closure caused this problem.

@jakepoz
Copy link

jakepoz commented Nov 28, 2018

We are seeing something similar, dev builds work fine, but production builds fail on Firefox, our promise catch is never being called.

@stale
Copy link

stale bot commented Dec 29, 2018

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Dec 29, 2018
@stale
Copy link

stale bot commented Jan 6, 2019

This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue.

@stale stale bot closed this as completed Jan 6, 2019
@lock lock bot locked and limited conversation to collaborators Jan 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants