{"record":{"id":"e59257919fd37eb7","repo":"vercel/next.js","slug":"invalidfilename","errorCode":"InvalidFilename","errorMessage":"file {name_or_path} is too long ({len}) exceeds filesystem limit of {limit}","messagePattern":"file (.+?) is too long \\((.+?)\\) exceeds filesystem limit of (.+?)","errorType":"exception","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"turbopack/crates/turbo-tasks-fs/src/disk.rs","lineNumber":74,"sourceCode":"///   32767 characters long.\n/// - On macOS, the limit is traditionally 255 characters for the file name and a second limit of\n///   1024 for the entire path (verified by running `getconf PATH_MAX /`).\n/// - On Linux, the limit differs between kernel (and by extension, distro) and filesystem. On most\n///   common file systems (e.g. ext4, btrfs, and xfs), individual file names can be up to 255 bytes\n///   with no hard limit on total path length. [Some legacy POSIX APIs are restricted to the\n///   `PATH_MAX` value of 4096 bytes in `limits.h`, but most applications support longer\n///   paths][PATH_MAX].\n///\n/// For more details, refer to <https://en.wikipedia.org/wiki/Comparison_of_file_systems#Limits>.\n///\n/// Realistically, the output path lengths will be the same across all platforms, so we need to set\n/// a conservative limit and be particular about when we decide to bump it. Here we have opted for\n/// 255 characters, because it is the shortest of the three options.\n///\n/// [PATH_MAX]: https://eklitzke.org/path-max-is-tricky\npub fn validate_path_length(path: &Path) -> io::Result<()> {\n    fn error(name_or_path: &str, len: usize, limit: usize) -> io::Error {\n        io::Error::new(\n            io::ErrorKind::InvalidFilename,\n            format!(\"file {name_or_path} is too long ({len}) exceeds filesystem limit of {limit}\"),\n        )\n    }\n    if cfg!(windows) {\n        // We always use verbatim paths internally in turbo-tasks-fs\n        debug_assert!(\n            matches!(\n                path.components().next(),\n                Some(std::path::Component::Prefix(prefix)) if prefix.kind().is_verbatim()\n            ),\n            \"expected a verbatim path, got {path:?}\",\n        );\n\n        // We subtract a 100-character safety margin from the real value because:\n        // > The maximum path of 32,767 characters is approximate, because the \"\\\\?\\\" prefix may\n        // > be expanded to a longer string by the system at run time, and this expansion\n        // > applies to the total length.","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/turbopack/crates/turbo-tasks-fs/src/disk.rs#L56-L92","documentation":"validate_path_length enforces conservative OS filesystem limits before any disk write. On Unix it rejects filenames whose byte length exceeds 255 (the common ext4/btrfs/xfs inode name limit); on macOS it also rejects total paths over 1016 bytes; on Windows it rejects verbatim paths over 32667 characters. The error is returned as io::ErrorKind::InvalidFilename.","triggerScenarios":"Turbopack generating an output asset/chunk whose filename exceeds 255 bytes — e.g. a content-hashed name with a very long original module identifier, or a deeply-named server-component chunk. Also macOS builds with total output paths exceeding ~1KB.","commonSituations":"Very long route segment or component names producing oversized chunk filenames; aggregated chunk names built from many concatenated module names; builds targeting macOS with deep output directory trees.","solutions":["Shorten the source module/route names that feed into the generated filename.","Configure chunk/asset naming to use a hash-only or shorter template to stay under 255 bytes.","Move the output directory closer to the filesystem root to reduce total path length (macOS)."],"exampleFix":"// before: long deterministic chunk name\nconfig.output = { filename: '[name].[contenthash].js' } // name can be hundreds of chars\n\n// after: hash-prefixed short name\nconfig.output = { filename: '[contenthash:8].js' }","handlingStrategy":"validation","validationCode":"// Check generated output filenames stay under the 255-byte limit (Node.js).\nconst MAX_NAME = 255;\nfunction assertNameLength(name) {\n  const len = Buffer.byteLength(name, 'utf8');\n  if (len > MAX_NAME) throw new Error(`filename too long: ${len} > ${MAX_NAME} bytes`);\n}\n","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use hash-based or short chunk-naming templates to keep generated filenames compact.","Avoid extremely long route/component names that flow into output filenames.","On macOS, keep the output directory shallow to stay under the ~1KB total path limit."],"tags":["filesystem","path-length","output","invalid-filename"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}