From 0ac693463c8dea929ab4e53fa2428e21cd1583d6 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Mon, 15 Jul 2024 17:17:55 +0200 Subject: [PATCH] fix unloading stateful check (vercel/turbo#8749) ### Description We need to move up the check so it prevents unloading tasks with state. ### Testing Instructions --- crates/turbo-tasks-memory/src/task.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/crates/turbo-tasks-memory/src/task.rs b/crates/turbo-tasks-memory/src/task.rs index 4d470de14d71c..8e508e42b6ac2 100644 --- a/crates/turbo-tasks-memory/src/task.rs +++ b/crates/turbo-tasks-memory/src/task.rs @@ -1621,22 +1621,22 @@ impl Task { } state.gc.generation = None; - if active { - let mut cells_to_drop = Vec::new(); - - match &mut state.state_type { - TaskStateType::Done { stateful, edges: _ } => { - if *stateful { - return GcResult::NotPossible; - } - } - TaskStateType::Dirty { .. } => {} - _ => { - // GC can't run in this state. We will reschedule it when the execution - // completes. + match &mut state.state_type { + TaskStateType::Done { stateful, edges: _ } => { + if *stateful { return GcResult::NotPossible; } } + TaskStateType::Dirty { .. } => {} + _ => { + // GC can't run in this state. We will reschedule it when the execution + // completes. + return GcResult::NotPossible; + } + } + + if active { + let mut cells_to_drop = Vec::new(); // shrinking memory and dropping cells state.aggregation_node.shrink_to_fit();