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(webpack): WebpackNxBuildCoordinationPlugin cancels inflight builds on new changes detected #18883

Merged

Conversation

Coly010
Copy link
Contributor

@Coly010 Coly010 commented Aug 29, 2023

Current Behavior

When changes occur quickly in succession, builds are queued, and processed synchronously.
An action such as changing between two branches quickly could lead to a long wait time as the previous build must be completed before the second build occurs.

Webpack also continues to build the application before the dependent projects have finished building.

Expected Behavior

Webpack should wait for the dependent projects to finish building before attempting to build the application.

When a build is currently in progress, if more changes are detected, the initial build should be cancelled, allowing the queue to start to process the next items.

Related Issue(s)

Fixes #

@Coly010 Coly010 requested a review from a team as a code owner August 29, 2023 13:48
@Coly010 Coly010 self-assigned this Aug 29, 2023
@vercel
Copy link

vercel bot commented Aug 29, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Visit Preview Aug 29, 2023 3:21pm

Comment on lines 72 to 61
} finally {
this.currentlyRunning = 'none';
}
}).then(() => {
this.currentlyRunning = 'none';
this.buildCmdProcess = null;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This ensures webpack will wait until the build of dependent projects has completed before continuing the webpack build

if (this.buildCmdProcess) {
this.buildCmdProcess.kill(2);
this.buildCmdProcess = null;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If new changes are detected, kill the current process running the build allowing the Promise to resolve, allowing the next item in the queue to be processed.

Consideration: An API for the BatchFunctionRunner to clear the queue before queuing a new build. There could be a potential issue where we have 3 builds queued, we detect changes, and we only cancel the first build, but there are still builds queued.
However, I haven't been able to produce this scenario in testing.

Copy link
Member

@jaysoo jaysoo left a comment

Choose a reason for hiding this comment

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

Approved, but can you check just changing the return new Promise to return await new Promise?

@Coly010 Coly010 force-pushed the webpack/kill-existing-build-before-queue branch from e1ccd6e to e0cc3b0 Compare August 29, 2023 15:21
@Coly010 Coly010 requested a review from jaysoo August 29, 2023 15:21
@Coly010 Coly010 merged commit b5380d0 into nrwl:master Aug 29, 2023
3 checks passed
@Coly010 Coly010 deleted the webpack/kill-existing-build-before-queue branch August 29, 2023 16:14
@github-actions
Copy link

github-actions bot commented Sep 4, 2023

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants