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

Async anonymous function get lost in production #7457

Open
vince1995 opened this issue Aug 1, 2019 · 4 comments
Open

Async anonymous function get lost in production #7457

vince1995 opened this issue Aug 1, 2019 · 4 comments

Comments

@vince1995
Copy link
Contributor

Describe the bug

I have a function which calls an async anonymous function. Everything is fine in development but in production the relevant code is lost.

My code:

    getPOIInformation = (index) => {
        const activePOIObject = pois[this.state.activePOIIndex];
        const properties = activePOIObject.geojson.features[index].properties;
        console.log(properties);

        if (!properties.additionalInformation) {

            properties.additionalInformation = "LOADING";

            (async function () {
                const response = await api.getPoiInformation({ type: properties.osmType, id: properties.id });
                properties.additionalInformation = response;
                this.forceUpdate();
            }).bind(this)();

        }

        return properties.additionalInformation;
    }

Code after run build:

a.getPOIInformation = function (e) {
        var t = qe[a.state.activePOIIndex].geojson.features[e].properties;
        return console.log(t),
            t.additionalInformation || (t.additionalInformation = "LOADING"),
            t.additionalInformation
    }

I think there is something in the webpack/babel configuration wrong.

@heyimalex
Copy link
Contributor

I can repro. I think it has to be terser, but it's honestly difficult to debug.

@kzc
Copy link

kzc commented Aug 7, 2019

This is a bug in Babel: babel/babel#10306

@kzc
Copy link

kzc commented Aug 8, 2019

Technically this is a Babel configuration issue combined with an issue in regenerator-transform.

@vince1995
Copy link
Contributor Author

@kzc so should I close this issue?

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

No branches or pull requests

3 participants