Skip to content

Commit

Permalink
fix recomputation when reading gc'ed cells from in progress tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Feb 12, 2025
1 parent 106e17c commit 72141e2
Showing 1 changed file with 38 additions and 4 deletions.
42 changes: 38 additions & 4 deletions turbopack/crates/turbo-tasks-backend/src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -724,10 +724,44 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
});

// Schedule the task, if not already scheduled
if task.add(CachedDataItem::new_scheduled(
self.get_task_desc_fn(task_id),
)) {
turbo_tasks.schedule(task_id);
if let Some(existing) = get!(task, InProgress) {
match existing {
InProgressState::InProgress(box InProgressStateInner { stale, .. }) => {
if !*stale {
let idx = get!(
task,
CellTypeMaxIndex {
cell_type: cell.type_id
}
)
.copied()
.unwrap_or_default();
if cell.index <= idx {
// The current execution is past the cell, so we need to reexecute.
let Some(InProgressState::InProgress(box InProgressStateInner {
stale,
..
})) = get_mut!(task, InProgress)
else {
unreachable!();
};
*stale = true;
} else {
// The cell will still be written in the current execution, so we can
// just continue here.
}
}
}
InProgressState::Scheduled { .. } => {
// Already scheduled
}
}
} else {

Check failure on line 759 in turbopack/crates/turbo-tasks-backend/src/backend/mod.rs

View workflow job for this annotation

GitHub Actions / rust check / build

this `else { if .. }` block can be collapsed
if task.add(CachedDataItem::new_scheduled(
self.get_task_desc_fn(task_id),
)) {
turbo_tasks.schedule(task_id);
}
}

Ok(Err(listener))
Expand Down

0 comments on commit 72141e2

Please sign in to comment.