ForbesLindesay / browserify-middleware

express middleware for browserify, done right
http://browserify.org
MIT License
381 stars 66 forks source link

Syntax errors don't show details about actual error #40

Closed atombender closed 10 years ago

atombender commented 10 years ago

Any syntax error will just re-throw the exception, which will be coming from esprima.js, and break the server:

/node_modules/envify/node_modules/falafel/node_modules/esprima/esprima.js:3817
            throw e;
                  ^
Error: Line 17: Unexpected identifier
    at throwError (/node_modules/envify/node_modules/falafel/node_modules/esprima/esprima.js:1456:21)
    at throwUnexpected (/node_modules/envify/node_modules/falafel/node_modules/esprima/esprima.js:1500:13)
    at expect (/node_modules/envify/node_modules/falafel/node_modules/esprima/esprima.js:1523:13)
    at parseObjectInitialiser (/node_modules/envify/node_modules/falafel/node_modules/esprima/esprima.js:1740:17)
    at parsePrimaryExpression (/node_modules/envify/node_modules/falafel/node_modules/esprima/esprima.js:1810:20)
    at /node_modules/envify/node_modules/falafel/node_modules/esprima/esprima.js:3574:38
    at trackLeftHandSideExpressionAllowCall (/node_modules/envify/node_modules/falafel/node_modules/esprima/esprima.js:3478:61)
    at parsePostfixExpression (/node_modules/envify/node_modules/falafel/node_modules/esprima/esprima.js:1927:20)
    at /node_modules/envify/node_modules/falafel/node_modules/esprima/esprima.js:3574:38
    at parseUnaryExpression (/node_modules/envify/node_modules/falafel/node_modules/esprima/esprima.js:1997:16)

See https://github.com/substack/node-browserify/issues/308, for example.

ForbesLindesay commented 10 years ago

We actually have a unit test for this, and it passes, so I can't reproduce this. If you are still able to reproduce this, please submit a pull request with a failing unit test and I'll try and get it passing.

atombender commented 10 years ago

Actually the bug disappeared, although I have no idea what I did to fix it — nothing in my own code, but it's possible that a recent Node.js upgrade fixed it, or something else in my package.json. Thanks, anyway.

ForbesLindesay commented 10 years ago

It's likely to have been one specific version of browserify that had this bug. Browserify quite frequently fails to properly handle errors. The only way to fix that reliably would be to run it in a separate process, but I don't really want to do that as it would have a massive performance hit.

railrhoad commented 9 years ago

I also see this same behavior here, unfortunately I'm not sure how to provide what you're looking for to help debug. Essentially any error gets eaten with this exact error trace and I can't tell where to diagnose.