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

fix: Exit status code for fatal Webpack exceptions #1754

Merged
merged 4 commits into from
Dec 17, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/spotty-singers-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'preact-cli': patch
---

Corrects status code when there is a fatal Webpack error in production builds
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
test:
name: Test
runs-on: ubuntu-latest
timeout-minutes: 10
Copy link
Member Author

@rschristian rschristian Dec 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated, but for some (godforsaken) reason, puppeteer randomly never exits on the CI. I've seen no pattern for this, just that it occurs.

GitHub's default is 360 minutes, or 6 hours, which we definitely don't need. I just caught a run still going after an hour and had to manually kill it. 10 minutes should be plenty of time.

strategy:
matrix:
node-version: [12.x, 14.x]
Expand Down
10 changes: 5 additions & 5 deletions packages/cli/src/lib/webpack/run-webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ async function prodBuild(env) {
}

function runCompiler(compiler) {
return new Promise((res, rej) => {
return new Promise(res => {
compiler.run((err, stats) => {
showStats(stats, true);

if (err || (stats && stats.hasErrors())) {
rej(`${red('\n\nBuild failed! \n\n')} ${err || ''}`);
if (err) {
error(err, 1);
}

showStats(stats, true);

Comment on lines -83 to +88
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

showStats(), in production builds, will also immediately exit upon coming across any errors; as such, there's no reason to ever reject this promise as we've already exited.

res(stats);
});
});
Expand Down