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

"ReferenceError: Invalid left-hand side expression in postfix operation" in production build #1681

Closed
gaearon opened this issue Feb 28, 2017 · 16 comments

Comments

@gaearon
Copy link
Contributor

gaearon commented Feb 28, 2017

Update: if you see this, you have a buggy version of UglifyJS (2.8.0).

Run rm -rf node_modules and then npm install (or yarn).

Then verify that node_modules/uglify-js/package.json has at least 2.8.1 in the version field. If not, you might need to clean your cache, or update your lockfile or shrinkwrap.

Original Post

I see this both in Windows and OS X tests.

  Integration
    Environment variables
Error: Uncaught [ReferenceError: Invalid left-hand side expression in postfix operation]
    at reportException (/tmp/tmp.sLfC3ipnAc/test-kitchensink/node_modules/jsdom/lib/jsdom/living/helpers/runtime-script-errors.js:58:24)
    at processJavaScript (/tmp/tmp.sLfC3ipnAc/test-kitchensink/node_modules/jsdom/lib/jsdom/living/nodes/HTMLScriptElement-impl.js:130:7)
    at HTMLScriptElementImpl._eval (/tmp/tmp.sLfC3ipnAc/test-kitchensink/node_modules/jsdom/lib/jsdom/living/nodes/HTMLScriptElement-impl.js:65:7)
    at /tmp/tmp.sLfC3ipnAc/test-kitchensink/node_modules/jsdom/lib/jsdom/browser/resource-loader.js:31:22
    at Object.check (/tmp/tmp.sLfC3ipnAc/test-kitchensink/node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:85:11)
    at ResourceQueue.resume (/tmp/tmp.sLfC3ipnAc/test-kitchensink/node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:119:12)
    at DocumentImpl.close (/tmp/tmp.sLfC3ipnAc/test-kitchensink/node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:518:17)
    at Document.close (/tmp/tmp.sLfC3ipnAc/test-kitchensink/node_modules/jsdom/lib/jsdom/living/generated/Document.js:322:27)
    at _callee$ (/tmp/tmp.sLfC3ipnAc/test-kitchensink/integration/initDOM.js:55:7)
    at tryCatch (/home/travis/build/facebookincubator/create-react-app/packages/babel-preset-react-app/node_modules/babel-runtime/node_modules/regenerator-runtime/runtime.js:64:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (/home/travis/build/facebookincubator/create-react-app/packages/babel-preset-react-app/node_modules/babel-runtime/node_modules/regenerator-runtime/runtime.js:299:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/home/travis/build/facebookincubator/create-react-app/packages/babel-preset-react-app/node_modules/babel-runtime/node_modules/regenerator-runtime/runtime.js:116:21)
    at step (/tmp/tmp.sLfC3ipnAc/test-kitchensink/integration/initDOM.js:13:191)
    at /tmp/tmp.sLfC3ipnAc/test-kitchensink/integration/initDOM.js:13:361
    at run (/tmp/tmp.sLfC3ipnAc/test-kitchensink/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:87:22)
    at /tmp/tmp.sLfC3ipnAc/test-kitchensink/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:100:28
    at flush (/tmp/tmp.sLfC3ipnAc/test-kitchensink/node_modules/babel-polyfill/node_modules/core-js/modules/_microtask.js:18:9)
    at nextTickCallbackWith0Args (node.js:489:9)
    at process._tickCallback (node.js:418:13) [ReferenceError: Invalid left-hand side expression in postfix operation]
@gaearon
Copy link
Contributor Author

gaearon commented Feb 28, 2017

@Timer Any ideas? Seems to only occur for production build.

@Timer
Copy link
Contributor

Timer commented Feb 28, 2017

Junk builds are being produced.
examples:

window.webpackJsonp=function(t,r,i){for(var a,u,s=[];0<t.length;0++)
throw l.framesToPop=1,l}}var o=function(e){};e.exports=r},function(e,t,n){"use strict"
function r(e){for(var t=arguments.length-1,n="Minified React error #"+e+"; visit http://facebook.github.io/react/docs/error-decoder.html?invariant="+e;0<t;0++)

note 0++ / 0 everywhere

@Timer
Copy link
Contributor

Timer commented Feb 28, 2017

I have a feeling one of our dependencies had a dep that updated and introduced a bug. Not sure if webpack or babel's fault, but looks like a compilation issue.

I'll have time to look at this in a little bit.

@Timer
Copy link
Contributor

Timer commented Feb 28, 2017

I would be interested to know if the 0.9.x branch still builds. Just fired off a rebuild on 0.9.x/HEAD: https://travis-ci.org/facebookincubator/create-react-app/builds/205512060

@Timer
Copy link
Contributor

Timer commented Feb 28, 2017

https://github.com/mishoo/UglifyJS2 recently released, but not when this error started happening.

@Timer
Copy link
Contributor

Timer commented Feb 28, 2017

I'm going to bet the regression was introduced here:
mishoo/UglifyJS@4e49302 and mishoo/UglifyJS@16cd5d5

They enabled something called reduce_vars by default, which I bet is replacing the loop variable with it's initial value.

@gaearon
Copy link
Contributor Author

gaearon commented Feb 28, 2017

Good investigation.

@gaearon
Copy link
Contributor Author

gaearon commented Feb 28, 2017

Shall we change our Uglify options in 0.9.3 to work around this?

@Timer
Copy link
Contributor

Timer commented Feb 28, 2017

I'm a bit tight on time for a few hours, but can you make a PR setting the uglify flag reduce_vars to false in the production webpack config and see if the PR CI passes?

@gaearon
Copy link
Contributor Author

gaearon commented Feb 28, 2017

mishoo/UglifyJS#1516

@existentialism
Copy link
Contributor

existentialism commented Feb 28, 2017

@Timer @gaearon I can send a PR 👍

@gaearon
Copy link
Contributor Author

gaearon commented Feb 28, 2017

I'm on it

@gaearon
Copy link
Contributor Author

gaearon commented Feb 28, 2017

#1682

@Timer
Copy link
Contributor

Timer commented Feb 28, 2017

Wow! I can't believe I didn't see that bug report (maybe I should've looked, would've saved me a few mins 😆).

@gaearon
Copy link
Contributor Author

gaearon commented Feb 28, 2017

OK, I think we don't need to fix it on our end because Uglify will push out a fix soon.
mishoo/UglifyJS#1516 (comment)

@gaearon gaearon changed the title CI is failing with a weird error "ReferenceError: Invalid left-hand side expression in postfix operation" in production build Feb 28, 2017
@gaearon
Copy link
Contributor Author

gaearon commented Feb 28, 2017

Fixed in uglify-js@2.8.1.

@gaearon gaearon closed this as completed Feb 28, 2017
@lock lock bot locked and limited conversation to collaborators Jan 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants