{"record":{"id":"8e11913353732bc2","repo":"rolldown/rolldown","slug":"entry-length-exceeds-u32-max","errorCode":null,"errorMessage":"Entry length exceeds u32::MAX","messagePattern":"Entry length exceeds u32::MAX","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/rolldown/src/stages/generate_stage/code_splitting.rs","lineNumber":90,"sourceCode":"        bits: BitSet::new(entries_len),\n        share_count: 0,\n        tags_bit_set: ModuleTagBitSet::default(),\n      }; self.link_output.module_table.modules.len()];\n    let mut bits_to_chunk = FxHashMap::with_capacity(entries_len as usize);\n\n    let input_base = ArcStr::from(\n      self\n        .get_common_dir_of_all_modules(self.link_output.module_table.modules.as_vec())\n        .unwrap_or_default(),\n    );\n    if self.options.preserve_modules {\n      let modules_len = self\n        .link_output\n        .module_table\n        .modules\n        .len()\n        .try_into()\n        .expect(\"Entry length exceeds u32::MAX\");\n      for (idx, module) in self.link_output.module_table.modules.iter_enumerated() {\n        let Module::Normal(module) = module else {\n          continue;\n        };\n        let matched_entry =\n          self.link_output.entries.get(&module.idx).and_then(|entries| entries.first());\n        if !self.link_output.metas[module.idx].is_included {\n          continue;\n        }\n\n        let count = idx.raw();\n        let mut bits = BitSet::new(modules_len);\n        bits.set_bit(count);\n        let mut chunk = Chunk::new(\n          matched_entry.and_then(|item| item.name.clone()),\n          matched_entry.and_then(|item| item.file_name.clone()),\n          bits.clone(),\n          vec![],","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/rolldown/rolldown/blob/91b44b9d7bcfb5725533478e044e3891a251b2c5/crates/rolldown/src/stages/generate_stage/code_splitting.rs#L72-L108","documentation":"While matching modules to their entries in code splitting, rolldown casts the module table length to u32. If the build contains more than u32::MAX modules, the cast overflows and panics. The message text ('Entry length') is misleading — the value is actually modules.len().","triggerScenarios":"self.link_output.module_table.modules.len() > u32::MAX at code_splitting.rs:90. Requires a bundle with over ~4.29 billion modules — a scalability ceiling, not a configuration error.","commonSituations":"Only reachable via synthetic stress tests, fuzzing, or generated mega-builds; unreachable for real-world projects.","solutions":["Reduce the module count of the build (it exceeds u32::MAX, far beyond any practical bundle)","If this is a legitimate workload, file an issue to widen the index type to u64/usize","For tooling that generates modules programmatically, cap generated module count"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// You cannot realistically count modules pre-build; guard at the tooling level by\n// refusing builds whose source tree contains an implausible module count\nconst { count } = await countSourceFiles(root);\nif (count >= 0xffffffff) throw new Error('Module count exceeds u32 index range');","typeGuard":null,"tryCatchPattern":"try {\n  const bundle = await rolldown(options);\n} catch (e) {\n  if (String(e.message).includes('Entry length exceeds u32::MAX')) {\n    // Split the build; the module count is beyond any supported scale\n  }\n}","preventionTips":["Avoid generating billions of modules in synthetic builds","Split extremely large monorepo bundles","Keep rolldown updated for index-width changes"],"tags":["rust","chunking","integer-overflow","scalability"],"backgroundTag":"value-out-of-range","analyzedSha":"91b44b9d7bcfb5725533478e044e3891a251b2c5","analyzedAt":"2026-09-07T16:04:13.504Z","contentChangedAt":"2026-09-07T16:04:13.504Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}