next.js
98e1133f - [turbopack] Simplify snapshotting logic (#91178)

Commit
38 days ago
[turbopack] Simplify snapshotting logic (#91178) ## Summary - **Use `modified` flags instead of `restored` flags** to decide which task data categories to encode during snapshots. Previously, `process` used `restored` flags (encoding any category that had been loaded into memory), while `process_snapshot` used `modified` flags. The `restored` check was overly conservative — it would re-serialize categories that were loaded from disk but never actually changed. Using `modified` for both paths only encodes categories that were actually dirtied, avoiding redundant re-persistence of clean data. - **Unify `process` and `process_snapshot` into a single callback** on `take_snapshot`. Since both closures now use the same logic (`modified` flags), the two-callback API was unnecessary. `take_snapshot` now takes a single `Fn(TaskId, &TaskStorage, &mut TurboBincodeBuffer) -> SnapshotItem` — for snapshot copies the `Box<TaskStorage>` is simply dereferenced before calling. - **Change transient task handling from silent empty return to `unreachable!`**, since transient tasks should never appear in the persistence path. ## Test plan - Existing snapshot/persistence tests should continue to pass - The `modified` flags are always set for any task that ends up in the modified map (via `track_modification_internal`), so no categories are missed
Author
Parents
Loading