Skip to content

Commit 328a74d

Browse files
authored
Turbopack: write tasks doesn't need to be session dependent, as effects will restore (#78727)
### What? Filesystem write task don't need to be session dependent. We don't need to reexecute them for that reason. We already emit an "effect" and that is still emitted after restoring from cache. Not making them session dependent avoids dirty updates and also tracking the task as dirty in the aggregated graph. But the "effect" is not-serializeable, so the write task will be recomputed to recompute the value of the effect, when trying to apply the effect.
1 parent 1113910 commit 328a74d

File tree

1 file changed

+8
-2
lines changed
  • turbopack/crates/turbo-tasks-fs/src

1 file changed

+8
-2
lines changed

turbopack/crates/turbo-tasks-fs/src/lib.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,10 @@ impl FileSystem for DiskFileSystem {
717717

718718
#[turbo_tasks::function(fs)]
719719
async fn write(&self, fs_path: FileSystemPath, content: Vc<FileContent>) -> Result<()> {
720-
mark_session_dependent();
720+
// You might be tempted to use `mark_session_dependent` here, but
721+
// `write` purely declares a side effect and does not need to be reexecuted in the next
722+
// session. All side effects are reexecuted in general.
723+
721724
let full_path = self.to_sys_path(fs_path).await?;
722725
let content = content.await?;
723726
let inner = self.inner.clone();
@@ -848,7 +851,10 @@ impl FileSystem for DiskFileSystem {
848851

849852
#[turbo_tasks::function(fs)]
850853
async fn write_link(&self, fs_path: FileSystemPath, target: Vc<LinkContent>) -> Result<()> {
851-
mark_session_dependent();
854+
// You might be tempted to use `mark_session_dependent` here, but
855+
// `write_link` purely declares a side effect and does not need to be reexecuted in the next
856+
// session. All side effects are reexecuted in general.
857+
852858
let full_path = self.to_sys_path(fs_path).await?;
853859
let content = target.await?;
854860
let inner = self.inner.clone();

0 commit comments

Comments
 (0)