Skip to content

Commit 8ea8677

Browse files
committed
improve error message with trace_task_dirty feature
1 parent 1124ac1 commit 8ea8677

File tree

1 file changed

+16
-5
lines changed
  • turbopack/crates/turbo-tasks-backend/src/backend/operation

1 file changed

+16
-5
lines changed

turbopack/crates/turbo-tasks-backend/src/backend/operation/invalidate.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,22 @@ pub fn make_task_dirty(
180180

181181
// There must be no way to invalidate immutable tasks. If there would be a way the task is not
182182
// immutable.
183-
debug_assert!(
184-
!task.is_immutable(),
185-
"Task {} is immutable, but was made dirty. This should not happen and is a bug.",
186-
ctx.get_task_description(task_id)
187-
);
183+
#[cfg(debug_assertions)]
184+
if task.is_immutable() {
185+
#[cfg(feature = "trace_task_dirty")]
186+
let extra_info = format!(
187+
" Invalidation cause: {}",
188+
TaskDirtyCauseInContext::new(&cause, ctx)
189+
);
190+
#[cfg(not(feature = "trace_task_dirty"))]
191+
let extra_info = "";
192+
193+
panic!(
194+
"Task {} is immutable, but was made dirty. This should not happen and is a \
195+
bug.{extra_info}",
196+
ctx.get_task_description(task_id),
197+
);
198+
}
188199

189200
make_task_dirty_internal(
190201
&mut task,

0 commit comments

Comments
 (0)