-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix(watch): only stop relevant tasks while watching for changes. #10846
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -106,6 +106,20 @@ impl Command { | |
| pub fn program(&self) -> &OsStr { | ||
| &self.program | ||
| } | ||
|
|
||
| pub fn task_name(&self) -> Option<(String, String)> { | ||
| let package = self | ||
| .env | ||
| .get(&OsString::from("TURBO_PACKAGE_NAME"))? | ||
| .to_str()? | ||
| .to_string(); | ||
| let task = self | ||
| .env | ||
| .get(&OsString::from("TURBO_TASK_NAME"))? | ||
| .to_str()? | ||
| .to_string(); | ||
| Some((package, task)) | ||
| } | ||
|
Comment on lines
+110
to
+122
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The View Details📝 Patch Detailsdiff --git a/crates/turborepo-lib/src/task_graph/visitor/command.rs b/crates/turborepo-lib/src/task_graph/visitor/command.rs
index 0b3cb4d74..c38cbb956 100644
--- a/crates/turborepo-lib/src/task_graph/visitor/command.rs
+++ b/crates/turborepo-lib/src/task_graph/visitor/command.rs
@@ -135,6 +135,10 @@ impl<'a> CommandProvider for PackageGraphCommandProvider<'a> {
cmd.env_clear();
cmd.envs(environment.iter());
+ // Set package and task name for selective task stopping
+ cmd.env("TURBO_PACKAGE_NAME", task_id.package());
+ cmd.env("TURBO_TASK_NAME", task_id.task());
+
// If the task has an associated proxy, then we indicate this to the underlying
// task via an env var
if self
AnalysisMissing environment variables breaks selective task stopping functionalityWhat fails: How to reproduce:
Result: All tasks continue running instead of selective stopping, breaking the granular watch mode functionality introduced in commit 688456031 Expected: Tasks should be selectively stopped based on package and task names when files change during watch mode Root cause: |
||
| } | ||
|
|
||
| impl From<Command> for tokio::process::Command { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
filter_tasks()method excludes the root node from the filtered graph, which could break task graph integrity and cause execution failures.View Details
📝 Patch Details
Analysis
Invalid root_index in Engine.filter_tasks() causes panic when accessing filtered task graph
What fails:
Engine::filter_tasks()incrates/turborepo-lib/src/engine/mod.rsexcludes root node from filtered graph but reuses originalroot_index, causing panic when accessingengine.task_graph[engine.root_index]How to reproduce:
Result: Panic with "index out of bounds" when trying to access root node via
root_indexin filtered engineExpected: Root node should be preserved in filtered graph and
root_indexshould point to valid node, consistent with other filtering methods likecreate_engine_for_interruptible_tasks()which correctly handle root node preservation