next.js
cc7e804c - turbo-tasks-gc: Invalidating a deleted task should be a no-op (#98614)

Commit
3 days ago
turbo-tasks-gc: Invalidating a deleted task should be a no-op (#98614) Make invalidating deleted tasks a no-op. Invalidators now represent a 'weak' reference to a task, and invalidations don't assert task existence. We know that the task exists when the invalidator is created but by the time an invalidation occurs it might not exist anymore. So treat the dependency as weak. Take care to not create 'blank' tasks when querying for them, this can confuse assertions that occur later. ## Why is this safe? Currently it is safe because we never reuse task ids, so invalidating a deleted task is perfectly reasonable, much like invalidating a non-active task, there is nothing to do In the future if we start reusing task ids, then this becomes an ABA problem. An invalidator can point at a new task. This is also not too bad, a spurious invalidation is self healing. Also most invalidators are not actually persisted which limits the risk. So we can either decide to build a mechanism to tear down these stale edges or tolerate spurious invalidations. I think we could make invalidator users subscribe to a 'deleted task id bus' which would allow them to drop references, this could be useful and then the few cases where we _persist_ invalidators (by way of `State` objects) would need to devise a new mechanism (or decide to tolerate the spurious invalidations) --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
Author
Parents
Loading