Skip to content

feat(task): support fast failure exit#202

Closed
fengmk2 wants to merge 1 commit intomainfrom
09-25-feat_task_support_fast_failure_exit
Closed

feat(task): support fast failure exit#202
fengmk2 wants to merge 1 commit intomainfrom
09-25-feat_task_support_fast_failure_exit

Conversation

@fengmk2
Copy link
Copy Markdown
Member

@fengmk2 fengmk2 commented Sep 25, 2025

TL;DR

Implement fail-fast behavior in the task execution pipeline to skip remaining tasks when a dependency fails.

image.png

What changed?

  • Modified ExecutionPlan::execute to track task failures and skip subsequent tasks
  • Added a new ExecutionFailure::SkippedDueToFailedDependency status for skipped tasks
  • Created a new snap test in packages/cli/snap-tests/fail-fast/ to verify the behavior
  • The test demonstrates that when a task fails, all dependent tasks are skipped with a clear indication in the execution summary

How to test?

Run the new snap test in the fail-fast directory:

cd packages/cli/snap-tests/fail-fast
vite run test
vite run ready

The output should show that when script2 fails, script3 is skipped. Similarly, in the nested case, when test fails (due to script2 failing), script4 is also skipped.

Why make this change?

This change improves the developer experience by not wasting time running tasks that are guaranteed to fail due to a dependency failure. It also provides clear feedback about why certain tasks were skipped, making it easier to diagnose and fix issues in the task pipeline.

Copy link
Copy Markdown
Member Author

fengmk2 commented Sep 25, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@fengmk2 fengmk2 self-assigned this Sep 25, 2025
@fengmk2 fengmk2 marked this pull request as ready for review September 25, 2025 06:52
Copilot AI review requested due to automatic review settings September 25, 2025 06:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements fail-fast behavior in the task execution pipeline where remaining tasks are skipped when a dependency fails. This prevents wasting time executing tasks that are guaranteed to fail and provides clear feedback about why tasks were skipped.

  • Adds tracking of task failures in ExecutionPlan::execute to skip subsequent tasks
  • Introduces ExecutionFailure::SkippedDueToFailedDependency status for skipped tasks
  • Creates comprehensive snap tests demonstrating fail-fast behavior in both simple and nested task scenarios

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/vite_task/src/schedule.rs Implements fail-fast logic by tracking failures and creating skipped execution statuses
packages/cli/snap-tests/fail-fast/package.json Defines test scripts with dependencies to demonstrate fail-fast behavior
packages/cli/snap-tests/fail-fast/failure.js Simple Node.js script that exits with code 1 to simulate task failure
packages/cli/snap-tests/fail-fast/steps.json Test configuration specifying commands and environment variables
packages/cli/snap-tests/fail-fast/snap.txt Expected output showing skipped tasks with clear dependency failure messages

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

if let Ok(exit_status) = status.execution_result {
if exit_status != 0 {
has_failed = true;
}
Copy link

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

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

The failure tracking logic only checks for non-zero exit codes but ignores Err cases. If execution_result is Err(ExecutionFailure::...), the task has failed but has_failed won't be set to true, allowing subsequent tasks to execute when they should be skipped.

Suggested change
}
}
} else {
// If execution_result is Err, treat as failure
has_failed = true;

Copilot uses AI. Check for mistakes.
→ Cache miss: no previous cache entry found
·······················································
[3] test: $ vite run script3 ⊘ (skipped: dependency failed)
→ Cache miss: no previous cache entry found
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's weird that skipped tasks still report cache status, since they don't look up cache at all.

let mut has_failed = false;
for step in self.steps {
execution_statuses.push(Self::execute_resolved_task(step, workspace).await?);
if has_failed {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This incorrectly skips tasks that are not yet executed but do not depend on the failed tasks.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, it looks like it can't be handled simply and needs to be determined based on the task_graph

@fengmk2 fengmk2 changed the base branch from main to graphite-base/202 September 25, 2025 07:05
@fengmk2 fengmk2 force-pushed the 09-25-feat_task_support_fast_failure_exit branch from f3c721a to 7217da0 Compare September 25, 2025 07:05
@fengmk2 fengmk2 changed the base branch from graphite-base/202 to 09-25-chore_task_remove_unuse_empty_line September 25, 2025 07:05
@fengmk2 fengmk2 marked this pull request as draft September 25, 2025 07:05
@fengmk2 fengmk2 force-pushed the 09-25-feat_task_support_fast_failure_exit branch from 7217da0 to 2705211 Compare September 25, 2025 07:39
@fengmk2 fengmk2 changed the base branch from 09-25-chore_task_remove_unuse_empty_line to graphite-base/202 September 25, 2025 07:54
@fengmk2 fengmk2 force-pushed the 09-25-feat_task_support_fast_failure_exit branch from 2705211 to b94cbbf Compare September 25, 2025 07:54
@graphite-app graphite-app Bot changed the base branch from graphite-base/202 to main September 25, 2025 07:54
@fengmk2 fengmk2 force-pushed the 09-25-feat_task_support_fast_failure_exit branch from b94cbbf to 7c54618 Compare September 25, 2025 07:55
@fengmk2 fengmk2 closed this Sep 25, 2025
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.

3 participants