{"record":{"id":"d12c9808cf8ea966","repo":"vercel/next.js","slug":"gave-up-applying-effects-after-max-retries-retri","errorCode":null,"errorMessage":"gave up applying effects after {MAX_RETRIES} retries; repeated effect-state divergence on: {keys:?}. This implies multiple routes are fighting to write one of these files.","messagePattern":"gave up applying effects after (.+?) retries; repeated effect-state divergence on: (.+?)\\. This implies multiple routes are fighting to write one of these files\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"turbopack/crates/turbo-tasks/src/effect.rs","lineNumber":635,"sourceCode":"/// `MAX_RETRIES`). Returns `Err` for terminal outcomes: a non-`Retry` error, or `Retry` after the\n/// retry budget is exhausted.\nfn handle_apply_retry(err: EffectsError, attempts: &mut usize) -> Result<()> {\n    const MAX_RETRIES: usize = 4; // chosen by a fair dice roll\n    match err {\n        EffectsError::Retry { keys } if *attempts < MAX_RETRIES => {\n            *attempts += 1;\n            // Warn on every retry after the first.\n            if *attempts > 1 {\n                tracing::warn!(\n                    attempts = *attempts,\n                    ?keys,\n                    \"retrying effect application; this implies multiple routes are fighting to \\\n                     write one of these files\",\n                );\n            }\n            Ok(())\n        }\n        EffectsError::Retry { keys } => anyhow::bail!(\n            \"gave up applying effects after {MAX_RETRIES} retries; repeated effect-state \\\n             divergence on: {keys:?}. This implies multiple routes are fighting to write one of \\\n             these files.\"\n        ),\n        e => Err(e.into()),\n    }\n}\n\n/// Build the deduped per-key indices into the captured slice. Detects per-key value-hash\n/// conflicts. This is the eager half of effect deduplication — it inspects only the captured\n/// effects themselves (no [`EffectStateStorage`] interaction) and is therefore safe to call\n/// from inside a turbo-tasks task in [`take_effects`].\nfn build_unique_keys(captured: &[Box<dyn CapturedEffect>]) -> UniqueKeys {\n    let mut by_key: FxHashMap<Box<[u8]>, usize> = FxHashMap::default();\n    for (idx, effect) in captured.iter().enumerate() {\n        match by_key.entry(effect.key()) {\n            hash_map::Entry::Vacant(entry) => {\n                entry.insert(idx);","sourceCodeStart":617,"sourceCodeEnd":653,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/turbopack/crates/turbo-tasks/src/effect.rs#L617-L653","documentation":"Thrown by handle_apply_retry() in turbo-tasks after MAX_RETRIES (4) failed attempts to apply effects because the effect state keeps diverging. Effects are Turbopack's mechanism for persisting side outputs (e.g. written files) during strongly-consistent resolution; persistent divergence means two different computations/routes are repeatedly trying to write the same file(s) with different content.","triggerScenarios":"Two or more routes or chunks in a Turbopack build produce conflicting content for the same output file key, so each apply invalidates the other's state and the retry loop never converges within 4 attempts.","commonSituations":"Multiple pages/app routes accidentally mapped to the same output asset path; a misconfigured manifest or chunk-naming collision; a Turbopack bug in effect deduplication for shared assets; custom output structure causing filename clashes.","solutions":["Inspect the `keys` in the error to identify which file(s) are being fought over, then find which routes both emit them.","Eliminate the collision: rename/differentiate the conflicting routes or assets so each file has a single producer.","Update to the latest Turbopack/Next.js version — effect-handling bugs are actively fixed.","If the keys are internal build artifacts, simplify the build graph (disable experimental features, reduce conflicting rewrites) to isolate the producer."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Avoid mapping multiple routes to the same output asset path.","Keep the build graph simple; disable experimental features that may duplicate producers.","Stay on the latest Next.js/Turbopack version to pick up effect-handling fixes.","When you see the warning about 'routes fighting to write a file', investigate the keys immediately."],"tags":["turbopack","turbo-tasks","effects","build","collision","turbo-tasks"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}