Skip to content

Commit 5dac448

Browse files
authored
Turbopack: fix and finish immutable tasks (#80996)
### What? Fixes the problems with the implementation of immutable tasks, adds tests and debug asserts to ensure it's working. * There was some confusion between children and dependencies. Children are not involved with immutablility, only dependencies are. * Opt out of immutablility for reading collectibles and for getting an invalidator. * Removed `#[turbo_tasks::function(invalidator)]` and the logic of discovering statically immutable with macro code. It won't work as local tasks are invisible and can cause dependencies Follow-up changes: * Technically immutability could be per cell instead of per task. A task produces immutable cells until it does something that depends on mutable cells or other opt-outs. It could be `RawVc::ImmutableCell` and the immutable flag would be only in `InProgressState` and not on a task.
1 parent cd3f868 commit 5dac448

37 files changed

+312
-218
lines changed

crates/next-api/src/project.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ impl ProjectContainer {
431431

432432
#[turbo_tasks::value_impl]
433433
impl ProjectContainer {
434-
#[turbo_tasks::function(invalidator)]
434+
#[turbo_tasks::function]
435435
pub async fn project(&self) -> Result<Vc<Project>> {
436436
let env_map: Vc<EnvMap>;
437437
let next_config;

crates/next-api/src/versioned_content_map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ impl VersionedContentMap {
213213
Ok(Vc::cell(None))
214214
}
215215

216-
#[turbo_tasks::function(invalidator)]
216+
#[turbo_tasks::function]
217217
pub async fn keys_in_path(&self, root: FileSystemPath) -> Result<Vc<Vec<RcStr>>> {
218218
let keys = {
219219
let map = &self.map_path_to_op.get().0;
@@ -230,7 +230,7 @@ impl VersionedContentMap {
230230
Ok(Vc::cell(keys))
231231
}
232232

233-
#[turbo_tasks::function(invalidator)]
233+
#[turbo_tasks::function]
234234
fn raw_get(&self, path: FileSystemPath) -> Vc<OptionMapEntry> {
235235
let assets = {
236236
let map = &self.map_path_to_op.get().0;

packages/next/src/build/swc/generated-native.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export interface NapiProjectOptions {
107107
/** A path inside the root_path which contains the app/pages directories. */
108108
projectPath: RcStr
109109
/**
110-
* next.config's distDir. Project initialization occurs eariler than
110+
* next.config's distDir. Project initialization occurs earlier than
111111
* deserializing next.config, so passing it as separate option.
112112
*/
113113
distDir: RcStr
@@ -153,7 +153,7 @@ export interface NapiPartialProjectOptions {
153153
/** A path inside the root_path which contains the app/pages directories. */
154154
projectPath?: RcStr
155155
/**
156-
* next.config's distDir. Project initialization occurs eariler than
156+
* next.config's distDir. Project initialization occurs earlier than
157157
* deserializing next.config, so passing it as separate option.
158158
*/
159159
distDir?: RcStr | undefined | null

turbopack/crates/turbo-tasks-backend/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ default = []
1717
print_cache_item_size = []
1818
verify_serialization = []
1919
verify_aggregation_graph = []
20+
verify_immutable = []
2021
trace_aggregation_update = []
2122
trace_find_and_schedule = []
2223
trace_task_completion = []

0 commit comments

Comments
 (0)