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

Using --bail makes module build errors more cryptic. #711

Closed
redfin-sasha-aickin opened this issue Jan 22, 2015 · 15 comments
Closed

Using --bail makes module build errors more cryptic. #711

redfin-sasha-aickin opened this issue Jan 22, 2015 · 15 comments
Labels

Comments

@redfin-sasha-aickin
Copy link

We use --bail so that webpack will report errors to our build script (without --bail, it doesn't give an error exit code).

Unfortunately, when you use --bail, the error result from unparseable JavaScript loses the line that tells you what file the error occurred in.

Example output without --bail:

Hash: 91ed442d775c1a722525
Version: webpack 1.4.13
Time: 3094ms
                                        Asset    Size  Chunks             Chunk Names
<snip>
    + 286 hidden modules

ERROR in ./pages/MyPage.js
Module build failed: Error: Parse Error: Line 7: Unexpected token ;
    at throwError (/Users/sashaaickin/code/main/corvair/node_modules/jsx-loader/node_modules/react-tools/node_modules/jstransform/node_modules/esprima-fb/esprima.js:2644:21)
    at throwUnexpected (/Users/sashaaickin/code/main/corvair/node_modules/jsx-loader/node_modules/react-tools/node_modules/jstransform/node_modules/esprima-fb/esprima.js:2706:9)
<snip>
    at parseProgramElement (/Users/sashaaickin/code/main/corvair/node_modules/jsx-loader/node_modules/react-tools/node_modules/jstransform/node_modules/esprima-fb/esprima.js:6185:16)
 @ ./target-entrypoints/MyPageEntry.js 4:17-68

With --bail, the output looks like:

ModuleBuildError: Module build failed: Error: Parse Error: Line 7: Unexpected token ;
    at throwError (/Users/sashaaickin/code/main/corvair/node_modules/jsx-loader/node_modules/react-tools/node_modules/jstransform/node_modules/esprima-fb/esprima.js:2644:21)
    at throwUnexpected (/Users/sashaaickin/code/main/corvair/node_modules/jsx-loader/node_modules/react-tools/node_modules/jstransform/node_modules/esprima-fb/esprima.js:2706:9)
<snip>
    at /Users/sashaaickin/code/main/corvair/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:270:15
    at runSyncOrAsync (/Users/sashaaickin/code/main/corvair/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:158:12)

Note that without --bail, the file with the syntax error (MyPage.js) is named, but not in the latter. This makes it hard to debug problems that come from our build script, because the error log does not tell us what file the problem is in.

@sapegin
Copy link
Member

sapegin commented Mar 23, 2015

Even more cryptic with loaders such as eslint-loader.

Without --bail:

Hash: 396f0bfb9d565b6f60f0
Version: webpack 1.7.3
Time: 1157ms
    + 1 hidden modules

ERROR in ./app/app.js

  5:78  error  Missing semicolon  semi

✖ 1 problem (1 error, 0 warnings)


ERROR in ./app/app.js
Module build failed: Error: Module failed because of a eslint error.
    at lint (/Users/admin/Dropbox/Projects/Misc/deliveryhero-test/node_modules/eslint-loader/index.js:54:15)
    at Object.module.exports (/Users/admin/Dropbox/Projects/Misc/deliveryhero-test/node_modules/eslint-loader/index.js:80:3)

With --bail:

ModuleBuildError: Module build failed: Error: Module failed because of a eslint error.
    at lint (/Users/admin/Dropbox/Projects/Misc/deliveryhero-test/node_modules/eslint-loader/index.js:54:15)
    at Object.module.exports (/Users/admin/Dropbox/Projects/Misc/deliveryhero-test/node_modules/eslint-loader/index.js:80:3)
    at DependenciesBlock.onModuleBuildFailed (/Users/admin/Dropbox/Projects/Misc/deliveryhero-test/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:303:19)
    at nextLoader (/Users/admin/Dropbox/Projects/Misc/deliveryhero-test/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:263:31)
    at /Users/admin/Dropbox/Projects/Misc/deliveryhero-test/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:285:15
    at runSyncOrAsync (/Users/admin/Dropbox/Projects/Misc/deliveryhero-test/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:171:4)
    at nextLoader (/Users/admin/Dropbox/Projects/Misc/deliveryhero-test/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:283:3)
    at Storage.finished (/Users/admin/Dropbox/Projects/Misc/deliveryhero-test/node_modules/webpack/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:38:16)
    at evalmachine.<anonymous>:272:14
    at /Users/admin/Dropbox/Projects/Misc/deliveryhero-test/node_modules/webpack/node_modules/enhanced-resolve/node_modules/graceful-fs/graceful-fs.js:102:5
    at Object.oncomplete (evalmachine.<anonymous>:108:15)

@ctumolosus
Copy link

I find this to be an undesirable effect as well.

@josephfinlayson
Copy link

Any pointers on how to fix this? We're having @sapegin 's problem.

@jhuntoo
Copy link

jhuntoo commented Mar 4, 2016

Any updates on this ?

This is a real pain, --bail is needed so that CI builds will fail when they should. However tslint-loader will not tell why it's failing.

This has been reported here : wbuchwalter/tslint-loader#18
and here: PatrickJS/PatrickJS-starter#374

For authors of loaders looking for a workaround, see how eslint-loader resolved this webpack-contrib/eslint-loader#53, by returning the errors or warnings in the exception message itself.

e.g. https://github.com/MoOx/eslint-loader/blob/master/index.js#L73

@jhuntoo
Copy link

jhuntoo commented Mar 4, 2016

AN issue with the workaround, when a loader returns an error and webpack bails, only the first error returns which could be tedious if you have a lot of errors and have to keep re running the build. Is there a way that webpack could allow a loader to report all errors and bail after all errors are known ?

@martpie
Copy link

martpie commented Jul 20, 2016

Hello ! Any news on this ?

@PhiLhoSoft
Copy link

I don't have this problem. Either it depends on config (I also use eslint-loader), or it has been fixed.

I have:

Hash: df6a9e09957b40770a92
Version: webpack 1.13.1
Time: 38200ms
[0] multi vendor 232 bytes {1} [built]
factory:0ms building:1ms = 1ms
[187] ./Project/app/scripts/features/settings ^./.*.html$ 729 bytes {0} [built]
... -> factory:253ms building:121ms
+ 232 hidden modules

ERROR in ./Project/app/scripts/services/slug.js

D:\Sources\Project\app\scripts\services\slug.js
185:15 error Missing semicolon semi

✖ 1 problem (1 error, 0 warnings)

on Windows 10.
My build launches webpack --bail --progress --profile

@khronic
Copy link

khronic commented Oct 4, 2016

Hey guys just wondering if there is any new update on this item?

@wyattjoh
Copy link

wyattjoh commented Nov 9, 2016

Also experiencing the same issue here.

@domenkozar
Copy link

domenkozar commented Feb 23, 2017

@jmitchell
Copy link

Here's a silly workaround. Given a webpack call without --bail called $RUN_WP,

$RUN_WP && $RUN_WP --bail

The first run gives you the detailed feedback about the error, and the second ensures you get a non-zero exit code when there's an error. This shouldn't be necessary, and is a hack.

jmitchell added a commit to input-output-hk/cardano-sl that referenced this issue Feb 23, 2017
@timraasveld
Copy link

timraasveld commented May 22, 2017

Based on @jmitchell's suggestion, I do the following to enable Bash command chaining, but only print the pretty (non --bail) error if it fails.

(webpack && webpack --bail > /dev/null 2>&1) && run_command_that_only_runs_on_webpack_success

@McGiogen
Copy link

McGiogen commented Apr 4, 2018

Any progress about this request? We will never build two times just to improve the logs...

@Janpot
Copy link
Member

Janpot commented Apr 7, 2018

I'm trying to reproduce this but adding the --bail flag makes no difference for me. Is this happening on the latest version? Does anybody have an example of a repo where this happens?

@ooflorent
Copy link
Member

I'm closing this issue since the problem is not reproducible using webpack 4 and webpack 3 is on maintenance mode.

eagerbeaver0353 added a commit to eagerbeaver0353/invoice-app-electron-angular that referenced this issue May 11, 2023
leonhiat added a commit to leonhiat/MFE-starter that referenced this issue Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests