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

webpack-cli@4 exits with 0 even when failing #1980

Closed
fregante opened this issue Oct 23, 2020 · 14 comments · Fixed by #1979
Closed

webpack-cli@4 exits with 0 even when failing #1980

fregante opened this issue Oct 23, 2020 · 14 comments · Fixed by #1979

Comments

@fregante
Copy link

Bug report

$ webpack should exit with a non-0 code when it finds an error in webpack.config.js

What is the current behavior?

$ webpack exits with 0 even if it throws a fatal error:

If the current behavior is a bug, please provide the steps to reproduce.

npm install -g webpack webpack-cli@4
echo '.' > webpack.config.js
webpack

Notice that webpack’s version is irrelevant. webpack-cli is the problem

What is the expected behavior?

webpack-cli@3 worked correctly, it exited with 1.

Other relevant information:
webpack version: 4 or 5 (webpack version irrelevant)
webpack-cli version: 4.1.0
Node.js version: v13.8.0
Operating System: macOS 10.15.4
Additional tools:

@webpack-bot
Copy link

For maintainers only:

  • webpack-4
  • webpack-5
  • bug
  • critical-bug
  • enhancement
  • documentation
  • performance
  • dependencies
  • question

fregante referenced this issue in refined-github/refined-github Oct 23, 2020
@snitin315
Copy link
Member

Thanks for the report I'm looking into it.

@fregante fregante changed the title webpack-cli@4 does not exit with non-0 code on error webpack-cli@4 exits with 0 even when failing Oct 23, 2020
@snitin315
Copy link
Member

Working fine for me.

Screenshot at 2020-10-23 07-47-54

@fregante
Copy link
Author

I don't know where you're testing because it doesn't work anywhere for me. Here's a plain GitHub Action workflow where CI passes even if webpack fails: https://github.com/fregante/webpack-issue-11789/runs/1296100000?check_suite_focus=true

name: CI
on: [push]
jobs:
  build:
    runs-on: ubuntu-latest
    steps: 
      - run: npm install webpack webpack-cli@4
      - run: echo '.' > webpack.config.js
      - run: npx webpack

@snitin315
Copy link
Member

Just added a test case for the same in #1979

@fregante
Copy link
Author

fregante commented Oct 23, 2020

The tests in that PR pass while my repro code still shows the issue on both GitHub Actions and my computer.

This means that the test effectively isn’t testing the same thing/environment.

@fregante
Copy link
Author

Here’s another workflow testing every major version of webpack-cli. Every version correctly fails except v4

https://github.com/fregante/webpack-issue-11789/runs/1297087059?check_suite_focus=true

@fregante
Copy link
Author

It's possible that #1971 fixed it just a couple of days ago but hasn't been pushed yet 🍰

@snitin315
Copy link
Member

can you try with the master branch?

@fregante
Copy link
Author

I tried but it's a monorepo, I don't know how to npm install that

@snitin315
Copy link
Member

You can create a symlink with npm link webpack-cli

@alexander-akait alexander-akait transferred this issue from webpack/webpack Oct 23, 2020
@alexander-akait
Copy link
Member

@fregante Can you create reproducible test repo, i think fixed in master

@fregante
Copy link
Author

fregante commented Oct 23, 2020

@evilebottnawi it's https://github.com/fregante/webpack-issue-11789

The repro is in GitHub Actions, it's only 3 lines:

npm install webpack webpack-cli@4
echo '.' > webpack.config.js
npx webpack

@benmvp
Copy link

benmvp commented Nov 9, 2020

Just ran into this problem. Upgraded to 4.2.0 and verified it worked. Thanks for the fix @snitin315!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants