Skip to content

webpack-cli v4-beta.8 ignoring loader's error. #1581

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
mstssk opened this issue May 25, 2020 · 9 comments · Fixed by #1736
Closed

webpack-cli v4-beta.8 ignoring loader's error. #1581

mstssk opened this issue May 25, 2020 · 9 comments · Fixed by #1736

Comments

@mstssk
Copy link

mstssk commented May 25, 2020

Describe the bug

webpack-cli v4-beta.8 ignoring loader's error.

Reproduction code: https://github.com/mstssk/webpack-cli-v4-beta8-ignore-loader-error

I wrote reproduction code of ts-loader, but this problem occurs with other loaders. e.g. file-loader.

What is the current behavior?

webpack-cli v3.3.11 fails and returns exit code 2 when an error occurs in loaders.
But webpack-cli v4.0.0-beta.8 does not fail and return exit code 0.

To Reproduce

Steps to reproduce the behavior:

  1. Setup webpack@4.43.0, webpack-cli@4.0.0-beta.8, and some loaders
  2. Write codes which raise error in loaders.
  3. Run webpack
  4. See error logs and status code.

Expected behavior

webpack fails and returns non-zero exit code when an error occurs in loaders.

Screenshots

Please paste the results of webpack-cli info here, and mention other relevant information

webpack-cli info fails in my env.

`webpack-cli info` Log
 $ npx webpack-cli info
[webpack-cli] Promise rejection: TypeError: Cannot convert undefined or null to object
[webpack-cli] TypeError: Cannot convert undefined or null to object
    at Function.entries (<anonymous>)
    at Object.<anonymous> (/private/tmp/webpack-cli-v4-beta8-ignore-loader-error/node_modules/@webpack-cli/info/index.js:45:41)
    at Generator.next (<anonymous>)
    at /private/tmp/webpack-cli-v4-beta8-ignore-loader-error/node_modules/@webpack-cli/info/index.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/private/tmp/webpack-cli-v4-beta8-ignore-loader-error/node_modules/@webpack-cli/info/index.js:4:12)
    at Object.info [as default] (/private/tmp/webpack-cli-v4-beta8-ignore-loader-error/node_modules/@webpack-cli/info/index.js:44:12)
    at Function.run (/private/tmp/webpack-cli-v4-beta8-ignore-loader-error/node_modules/webpack-cli/lib/commands/ExternalCommand.js:34:51)
    at WebpackCLI.runCommand (/private/tmp/webpack-cli-v4-beta8-ignore-loader-error/node_modules/webpack-cli/lib/webpack-cli.js:286:60)
    at runCLI (/private/tmp/webpack-cli-v4-beta8-ignore-loader-error/node_modules/webpack-cli/lib/bootstrap.js:61:26)

Additional context

#1222 (comment)

@consp1racy
Copy link

✖ 「atl」: Checking finished with 2 errors

and exits with 0.

@alexander-akait
Copy link
Member

/cc @webpack/cli-team need fix and tests

@snitin315
Copy link
Member

snitin315 commented Aug 1, 2020

I will debug it.

@snitin315
Copy link
Member

snitin315 commented Aug 6, 2020

@mstssk I have the following observations

with webpack-4 and webpack-cli@3 - (As expected)

Screenshot at 2020-08-06 14-29-11

with webpack-4 and webpack-cli@4.0.0-beta.8 - (Not as expected)

Screenshot at 2020-08-06 14-29-34

with webpack@next and webpack-cli next branch (As expected)

Screenshot at 2020-08-06 14-42-43

@snitin315
Copy link
Member

Expected behavior
webpack fails and returns exit code 0 when an error occurs in loaders.

Exit code 0 means the code was executed successfully without any failures. So if webpack fails it should exit with a non-zero exit code. Please correct me if I'm wrong.

@mstssk
Copy link
Author

mstssk commented Aug 6, 2020

@snitin315 Thank you for your help.

Expected behavior
webpack fails and returns exit code 0 when an error occurs in loaders.

Oops! I typoed it.
non-zero exit code is correct.

I edit this issue's description.
Thank you.

@snitin315
Copy link
Member

snitin315 commented Aug 6, 2020

I think then it's working as expected against the webpack-cli next branch I will add tests for the same.

@alexander-akait
Copy link
Member

@snitin315 Can you add test on this?

@snitin315
Copy link
Member

Yes. Work in progress.

evenstensberg pushed a commit that referenced this issue Aug 19, 2020
* tests: loader's error regression test for #1581

* tests: add test on error code

* tests: add tests in case of warnings from loader

Co-authored-by: Anshuman Verma <anshu.av97@gmail.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants