next.js
fa60f505 - turbo-tasks: Fix recomputation loop by allowing cell cleanup on error during recomputation (#92725)

Commit
1 day ago
turbo-tasks: Fix recomputation loop by allowing cell cleanup on error during recomputation (#92725) ### What? Fix an infinite recomputation loop in turbo-tasks by allowing cell cleanup to proceed during recomputation even when the task result is an error. ### Why? When a task errors during normal execution, cell cleanup is intentionally skipped. The rationale is that errors during normal execution are often transient eventual-consistency issues caused by reading stale inputs — keeping old cell data prevents "cell no longer exists" errors for dependent tasks that are reading those cells. However, during **recomputation** (a task re-executing without being marked dirty), nothing about its inputs has changed. Any error it produces is therefore not transient. If cell cleanup is skipped in this case, stale cells remain in place, which trigger further recomputations, which produce further errors, which skip further cleanups — creating an infinite loop. ### How? - Detect whether a task execution is a recomputation by checking `task.is_dirty().is_none()` at completion time (a recomputing task was not dirty when it started executing). - Propagate `is_recomputation` through `TaskExecutionCompletePrepareResult` to both `task_execution_completed_prepare` and `task_execution_completed_cleanup`. - In both places where cell cleanup is gated on `result.is_ok()` / `!is_error`, extend the condition to also allow cleanup when `is_recomputation` is true. This ensures that stale cells produced by a erroring recomputation are cleaned up, breaking the infinite loop. <!-- NEXT_JS_LLM_PR --> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
Parents
Loading