{"record":{"id":"9f86a33702b38e14","repo":"vercel/next.js","slug":"evict-last-is-only-valid-with-serialization","errorCode":null,"errorMessage":"evict = \"last\" is only valid with serialization = \"skip\"","messagePattern":"evict = \"last\" is only valid with serialization = \"skip\"","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"critical","filePath":"turbopack/crates/turbo-tasks-macros/src/value_macro.rs","lineNumber":311,"sourceCode":"            proc_macro2::Span::call_site(),\n            \"hash = \\\"manual\\\" only makes sense with serialization = \\\"hash\\\"\",\n        )\n        .to_compile_error()\n        .into();\n    }\n\n    // `evict = \"last\"` only makes sense for `serialization = \"skip\"`: it\n    // says \"re-deriving this cell is expensive\", and re-derivation is the\n    // recovery path only for skip mode. Persistable cells restore from disk\n    // (predictable cost), HashOnly cells short-circuit on unchanged hash.\n    //\n    // `evict = \"never\"` is allowed with any serialization mode — a value\n    // type can be persistable AND hold session-scoped state that must not\n    // leave memory (e.g. `DiskFileSystem` carrying file watchers).\n    if matches!(evict_mode, EvictMode::Last)\n        && !matches!(serialization_mode, SerializationMode::Skip)\n    {\n        return syn::Error::new(\n            proc_macro2::Span::call_site(),\n            \"evict = \\\"last\\\" is only valid with serialization = \\\"skip\\\"\",\n        )\n        .to_compile_error()\n        .into();\n    }\n\n    let mut struct_attributes = vec![quote! {\n        #[derive(\n            turbo_tasks::ShrinkToFit,\n            turbo_tasks::trace::TraceRawVcs,\n            turbo_tasks::NonLocalValue\n        )]\n        #[shrink_to_fit(crate = \"turbo_tasks::macro_helpers::shrink_to_fit\")]\n    }];\n\n    let mut inner_type = None;\n    if transparent {","sourceCodeStart":293,"sourceCodeEnd":329,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/turbopack/crates/turbo-tasks-macros/src/value_macro.rs#L293-L329","documentation":"Compile-time error from the #[turbo_tasks::value] proc-macro. evict = \"last\" marks a cell as expensive to re-derive so the eviction policy prefers evicting cheaper cells first — but re-derivation is only the recovery path for serialization = \"skip\". Persistable cells restore from disk and HashOnly cells short-circuit on an unchanged hash, so evict = \"last\" with those modes is meaningless and the macro rejects it. (evict = \"never\" is allowed with any serialization mode.)","triggerScenarios":"Annotating a value type with evict = \"last\" and a serialization mode other than \"skip\", e.g. #[turbo_tasks::value(serialization = \"auto\", evict = \"last\")] or serialization = \"hash\".","commonSituations":"A contributor marking a heavy-to-compute value as evict = \"last\" without realizing the hint only applies to skip-serialization types; copy-pasting attributes across types with different serialization modes.","solutions":["Set serialization = \"skip\" to make evict = \"last\" meaningful: #[turbo_tasks::value(serialization = \"skip\", evict = \"last\")].","Or remove evict = \"last\" if the value is persistable and eviction ordering is not needed.","If you need non-eviction for a persistable type, use evict = \"never\" instead, which is valid with any serialization mode."],"exampleFix":"// before\n#[turbo_tasks::value(serialization = \"auto\", evict = \"last\")]\nstruct HeavyCache { ... }\n\n// after\n#[turbo_tasks::value(serialization = \"skip\", evict = \"last\")]\nstruct HeavyCache { ... }","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only set evict = \"last\" together with serialization = \"skip\".","For persistable types that must not be evicted, use evict = \"never\" (valid with any serialization mode).","Remember evict hints only affect re-derivation cost, which is the recovery path solely for skip mode."],"tags":["proc-macro","turbo-tasks","value-attributes","eviction","compile-error"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}