{"record":{"id":"9a70cf81ffe5f4be","repo":"zed-industries/zed","slug":"file-is-too-large-to-load","errorCode":null,"errorMessage":"File is too large to load","messagePattern":"File is too large to load","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/worktree/src/worktree.rs","lineNumber":1725,"sourceCode":"        let abs_path = self.absolutize(&path);\n        let fs = self.fs.clone();\n        let entry = self.refresh_entry(path.clone(), None, cx);\n        let is_private = self.is_path_private(path.as_ref());\n\n        let this = cx.weak_entity();\n        cx.background_spawn(async move {\n            // WARN: Temporary workaround for #27283.\n            //       We are not efficient with our memory usage per file, and use in excess of 64GB for a 10GB file\n            //       Therefore, as a temporary workaround to prevent system freezes, we just bail before opening a file\n            //       if it is too large\n            //       5GB seems to be more reasonable, peaking at ~16GB, while 6GB jumps up to >24GB which seems like a\n            //       reasonable limit\n            const FILE_SIZE_MAX: u64 = 6 * 1024 * 1024 * 1024; // 6GB\n            let metadata = fs.metadata(&abs_path).await?;\n            if let Some(metadata) = metadata.as_ref()\n                && metadata.len >= FILE_SIZE_MAX\n            {\n                anyhow::bail!(\"File is too large to load\");\n            }\n            let (text, line_ending, encoding, has_bom) =\n                decode_file_text_to_rope(fs.as_ref(), &abs_path).await?;\n            let is_writable = metadata.is_some_and(|metadata| metadata.is_writable);\n\n            let worktree = this.upgrade().context(\"worktree was dropped\")?;\n            let file = match entry.await? {\n                Some(entry) => File::for_entry(entry, worktree),\n                None => {\n                    let metadata = fs\n                        .metadata(&abs_path)\n                        .await\n                        .with_context(|| {\n                            format!(\"Loading metadata for excluded file {abs_path:?}\")\n                        })?\n                        .with_context(|| {\n                            format!(\"Excluded file {abs_path:?} got removed during loading\")\n                        })?;","sourceCodeStart":1707,"sourceCodeEnd":1743,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/worktree/src/worktree.rs#L1707-L1743","documentation":"Loading a file via worktree is skipped because the file exceeds the size limit; as a workaround for memory blowup (#27283, ~64GB RAM for a 10GB file), the worktree bails before reading to prevent system freezes.","triggerScenarios":"Thrown at crates/worktree/src/worktree.rs:1719 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Open a smaller file or reduce the selection; this guard exists because memory usage per loaded file can exceed 6x file size (workaround for #27283)","Increase available system memory or raise the configured size limit if the environment allows it","Use terminal commands or external tools to inspect the large file instead of loading it in the editor"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9d272b036335401f339d024ea94968fd51016c40","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}