Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
77 changes: 43 additions & 34 deletions crates/vite_task/src/session/execute/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,21 @@ impl ExecutionContext<'_> {
LeafExecutionKind::InProcess(in_process_execution) => {
// In-process (built-in) commands: caching is disabled, execute synchronously
let mut stdio_config = leaf_reporter
.start(CacheStatus::Disabled(CacheDisabledReason::InProcessExecution));
.start(CacheStatus::Disabled(CacheDisabledReason::InProcessExecution))
.await;

let execution_output = in_process_execution.execute();
// Write output to the stdout writer from StdioConfig
let _ = stdio_config.stdout_writer.write_all(&execution_output.stdout).await;
let _ = stdio_config.stdout_writer.flush().await;

leaf_reporter.finish(
None,
CacheUpdateStatus::NotUpdated(CacheNotUpdatedReason::CacheDisabled),
None,
);
leaf_reporter
.finish(
None,
CacheUpdateStatus::NotUpdated(CacheNotUpdatedReason::CacheDisabled),
None,
)
.await;
}
LeafExecutionKind::Spawn(spawn_execution) => {
#[expect(
Expand Down Expand Up @@ -191,11 +194,13 @@ pub async fn execute_spawn(
Err(err) => {
// Cache lookup error — report through finish.
// Note: start() is NOT called because we don't have a valid cache status.
leaf_reporter.finish(
None,
CacheUpdateStatus::NotUpdated(CacheNotUpdatedReason::CacheDisabled),
Some(ExecutionError::Cache { kind: CacheErrorKind::Lookup, source: err }),
);
leaf_reporter
.finish(
None,
CacheUpdateStatus::NotUpdated(CacheNotUpdatedReason::CacheDisabled),
Some(ExecutionError::Cache { kind: CacheErrorKind::Lookup, source: err }),
)
.await;
return SpawnOutcome::Failed;
}
}
Expand All @@ -206,7 +211,7 @@ pub async fn execute_spawn(

// 2. Report execution start with the determined cache status.
// Returns StdioConfig with the reporter's suggestion and async writers.
let mut stdio_config = leaf_reporter.start(cache_status);
let mut stdio_config = leaf_reporter.start(cache_status).await;

// 3. If cache hit, replay outputs via the StdioConfig writers and finish early.
// No need to actually execute the command — just replay what was cached.
Expand All @@ -219,11 +224,9 @@ pub async fn execute_spawn(
let _ = writer.write_all(&output.content).await;
let _ = writer.flush().await;
}
leaf_reporter.finish(
None,
CacheUpdateStatus::NotUpdated(CacheNotUpdatedReason::CacheHit),
None,
);
leaf_reporter
.finish(None, CacheUpdateStatus::NotUpdated(CacheNotUpdatedReason::CacheHit), None)
.await;
return SpawnOutcome::CacheHit;
}

Expand All @@ -243,19 +246,23 @@ pub async fn execute_spawn(

match spawn_inherited(&spawn_execution.spawn_command).await {
Ok(result) => {
leaf_reporter.finish(
Some(result.exit_status),
CacheUpdateStatus::NotUpdated(CacheNotUpdatedReason::CacheDisabled),
None,
);
leaf_reporter
.finish(
Some(result.exit_status),
CacheUpdateStatus::NotUpdated(CacheNotUpdatedReason::CacheDisabled),
None,
)
.await;
return SpawnOutcome::Spawned(result.exit_status);
}
Err(err) => {
leaf_reporter.finish(
None,
CacheUpdateStatus::NotUpdated(CacheNotUpdatedReason::CacheDisabled),
Some(ExecutionError::Spawn(err)),
);
leaf_reporter
.finish(
None,
CacheUpdateStatus::NotUpdated(CacheNotUpdatedReason::CacheDisabled),
Some(ExecutionError::Spawn(err)),
)
.await;
return SpawnOutcome::Failed;
}
}
Expand All @@ -280,11 +287,13 @@ pub async fn execute_spawn(
{
Ok(result) => result,
Err(err) => {
leaf_reporter.finish(
None,
CacheUpdateStatus::NotUpdated(CacheNotUpdatedReason::CacheDisabled),
Some(ExecutionError::Spawn(err)),
);
leaf_reporter
.finish(
None,
CacheUpdateStatus::NotUpdated(CacheNotUpdatedReason::CacheDisabled),
Some(ExecutionError::Spawn(err)),
)
.await;
return SpawnOutcome::Failed;
}
};
Expand Down Expand Up @@ -337,7 +346,7 @@ pub async fn execute_spawn(
// 7. Finish the leaf execution with the result and optional cache error.
// Cache update/fingerprint failures are reported but do not affect the outcome —
// the process ran, so we return its actual exit status.
leaf_reporter.finish(Some(result.exit_status), cache_update_status, cache_error);
leaf_reporter.finish(Some(result.exit_status), cache_update_status, cache_error).await;

SpawnOutcome::Spawned(result.exit_status)
}
Expand Down Expand Up @@ -409,6 +418,6 @@ impl Session<'_> {

// Leaf-level errors and non-zero exit statuses are tracked internally
// by the reporter.
reporter.finish()
reporter.finish().await
}
}
11 changes: 8 additions & 3 deletions crates/vite_task/src/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,10 @@ impl<'a> Session<'a> {
.await
}
Ok(graph) => {
let builder = LabeledReporterBuilder::new(self.workspace_path());
let builder = LabeledReporterBuilder::new(
self.workspace_path(),
Box::new(tokio::io::stdout()),
);
Ok(self
.execute_graph(graph, Box::new(builder))
.await
Expand Down Expand Up @@ -391,7 +394,8 @@ impl<'a> Session<'a> {

let cwd = Arc::clone(&self.cwd);
let graph = self.plan_from_cli_run(cwd, run_command).await?;
let builder = LabeledReporterBuilder::new(self.workspace_path());
let builder =
LabeledReporterBuilder::new(self.workspace_path(), Box::new(tokio::io::stdout()));
Ok(self.execute_graph(graph, Box::new(builder)).await.err().unwrap_or(ExitStatus::SUCCESS))
}

Expand Down Expand Up @@ -467,7 +471,8 @@ impl<'a> Session<'a> {
let cache = self.cache()?;

// Create a plain (standalone) reporter — no graph awareness, no summary
let plain_reporter = reporter::PlainReporter::new(silent_if_cache_hit);
let plain_reporter =
reporter::PlainReporter::new(silent_if_cache_hit, Box::new(tokio::io::stdout()));

// Execute the spawn directly using the free function, bypassing the graph pipeline
match execute::execute_spawn(
Expand Down
Loading