Skip to content

Introduce --fail-fast flag for npm run in workspaces#8323

Open
bralax wants to merge 4 commits into
npm:latestfrom
bralax:latest
Open

Introduce --fail-fast flag for npm run in workspaces#8323
bralax wants to merge 4 commits into
npm:latestfrom
bralax:latest

Conversation

@bralax
Copy link
Copy Markdown

@bralax bralax commented May 25, 2025

Right now, when using npm run --workspaces {cmd} or npm run -w {package1} -w {package2} {cmd}, npm will always run the command in every single package even if some packages fail.

This means that if packages depend on each other and the first package fails, the second package will still try to be built and also crash. This both wastes resources as we are running commands that we know will fail and also has the potential to corrupt or generate corrupt output as the conditions to execute the command are not met.

To handle this, this pull request introduces a new command line flag for use with npm run when working with workspaces named --fail-fast that when provided, rather than running the specified command in every package no matter success, once the first package fails, the command will stop running.

This flag was originally proposed in this RFC. The conversation in the RFC got blocked due to discussion about how this would benefit from also implementing topological sort for workspace packages which requires a lot more thought and careful handling. This flag is useful even without topological sort and can be implemented in a backwards compatible way with immediate impact to users so I decided to submit it as a community contribution.

References

Related to: npm/rfcs#575

@bralax bralax requested a review from a team as a code owner May 25, 2025 15:35
@RomainFallet
Copy link
Copy Markdown

Any news on when this PR can be merged?

anthonyting added a commit to aws/aws-durable-execution-sdk-js that referenced this pull request Oct 6, 2025
*Issue #, if available:*

*Description of changes:*

Builds continue when previous builds fail. NPM has an active discussion
and PR to fix it npm/cli#8323, but it's not
merged yet.


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
ParidelPooya pushed a commit to aws/aws-durable-execution-sdk-js that referenced this pull request Oct 10, 2025
*Issue #, if available:*

*Description of changes:*

Builds continue when previous builds fail. NPM has an active discussion
and PR to fix it npm/cli#8323, but it's not
merged yet.


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
ParidelPooya pushed a commit to aws/aws-durable-execution-sdk-js that referenced this pull request Oct 12, 2025
*Issue #, if available:*

*Description of changes:*

Builds continue when previous builds fail. NPM has an active discussion
and PR to fix it npm/cli#8323, but it's not
merged yet.


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
ParidelPooya pushed a commit to aws/aws-durable-execution-sdk-js that referenced this pull request Oct 24, 2025
*Issue #, if available:*

*Description of changes:*

Builds continue when previous builds fail. NPM has an active discussion
and PR to fix it npm/cli#8323, but it's not
merged yet.


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
ParidelPooya pushed a commit to aws/aws-durable-execution-sdk-js that referenced this pull request Oct 26, 2025
*Issue #, if available:*

*Description of changes:*

Builds continue when previous builds fail. NPM has an active discussion
and PR to fix it npm/cli#8323, but it's not
merged yet.


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
ParidelPooya pushed a commit to aws/aws-durable-execution-sdk-js that referenced this pull request Nov 2, 2025
*Issue #, if available:*

*Description of changes:*

Builds continue when previous builds fail. NPM has an active discussion
and PR to fix it npm/cli#8323, but it's not
merged yet.


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
ParidelPooya pushed a commit to aws/aws-durable-execution-sdk-js that referenced this pull request Nov 6, 2025
*Issue #, if available:*

*Description of changes:*

Builds continue when previous builds fail. NPM has an active discussion
and PR to fix it npm/cli#8323, but it's not
merged yet.


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
ParidelPooya pushed a commit to aws/aws-durable-execution-sdk-js that referenced this pull request Nov 6, 2025
*Issue #, if available:*

*Description of changes:*

Builds continue when previous builds fail. NPM has an active discussion
and PR to fix it npm/cli#8323, but it's not
merged yet.


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
ParidelPooya pushed a commit to aws/aws-durable-execution-sdk-js that referenced this pull request Nov 6, 2025
*Issue #, if available:*

*Description of changes:*

Builds continue when previous builds fail. NPM has an active discussion
and PR to fix it npm/cli#8323, but it's not
merged yet.


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
ParidelPooya pushed a commit to aws/aws-durable-execution-sdk-js that referenced this pull request Nov 7, 2025
*Issue #, if available:*

*Description of changes:*

Builds continue when previous builds fail. NPM has an active discussion
and PR to fix it npm/cli#8323, but it's not
merged yet.


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
@zymotik
Copy link
Copy Markdown

zymotik commented Jun 3, 2026

Yes please!!

@owlstronaut
Copy link
Copy Markdown
Contributor

@zymotik @RomainFallet @bralax I'm happy to take a look at this if @bralax or somebody wants to bring it up to date. Also, let's use --bail, we can match what the convention of other tools in the ecosystem since we don't have any precedent here

@bralax bralax requested a review from a team as a code owner June 4, 2026 03:05
@bralax
Copy link
Copy Markdown
Author

bralax commented Jun 4, 2026

@owlstronaut The pull request has been rebased and swapped to --bail if you can review.

Comment thread lib/commands/run.js Outdated
Copy link
Copy Markdown

@Frank122480 Frank122480 left a comment

Choose a reason for hiding this comment

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

:-)

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 this pull request may close these issues.

7 participants