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

Minification error from 2.4.1 to 2.5.8 #12070

Closed
radekmie opened this issue Jun 30, 2022 · 2 comments
Closed

Minification error from 2.4.1 to 2.5.8 #12070

radekmie opened this issue Jun 30, 2022 · 2 comments

Comments

@radekmie
Copy link
Collaborator

In one of our projects, we're still using the old kadira:flow-router@2.12.1. It works for us well and we don't feel the urge to migrate off it. But now I wanted to update our project to the latest pre-2.6 version (we're still behind the schedule with the MongoDB driver), and it fails.

The error says "redirect needs to be done in sync", and comes from runTriggers.

Now, here's the minified code from 2.4.1:

h.runTriggers = function(t, e, r, n) {
    for (var i = !1, o = !0, a = !1, s = 0; s < t.length; s++) {
        var u;
        if ((0,
        t[s])(e, c, p),
        i)
            return
    }
    function c(t, e, n) {
        if (a)
            throw new Error("already redirected");
        if (!o)
            throw new Error("redirect needs to be done in sync");
        if (!t)
            throw new Error("trigger redirect requires an URL");
        i = !0,
        a = !0,
        r(t, e, n)
    }
    function p() {
        i = !0
    }
    o = !1,
    n()
}

And from 2.5.8:

h.runTriggers = function(t, e, r, n) {
    for (var i = !1, o = !0, a = !1, s = 0; s < t.length; s++) {
        var u;
        if ((0,
        t[s])(e, c, p),
        i)
            return
    }
    function c(t, e, r) {
        if (a)
            throw new Error("already redirected");
        throw new Error("redirect needs to be done in sync")
    }
    function p() {
        i = !0
    }
    o = !1,
    n()
}

Most importantly, variable o vanishes in the latter. We're using zodern:standard-minifier-js@4.1.1, but the same happens with standard-minifier-js@2.8.0. (Downgrading them causes different errors.)

@zodern
Copy link
Member

zodern commented Jun 30, 2022

@harryadel and I published a fork of flow router that rewrites this function to avoid the minifier bug: https://atmospherejs.com/montiapm/flow-router

Some more information for this bug is in #11756.

@radekmie
Copy link
Collaborator Author

radekmie commented Jul 1, 2022

OK, it worked, thanks! We can close it as the workaround is pretty straightforward (although I couldn't find #11756 while looking for an existing report).

@denihs denihs closed this as completed Jul 11, 2022
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