{"record":{"id":"35d5d1b7c72a6ef3","repo":"leptos-rs/leptos","slug":"failed-to-read-hash-file","errorCode":null,"errorMessage":"failed to read hash file","messagePattern":"failed to read hash file","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"leptos/src/hydration/mod.rs","lineNumber":73,"sourceCode":"    /// A base url, not including a trailing slash\n    #[prop(optional, into)]\n    root: Option<String>,\n) -> impl IntoView {\n    static SPLIT_MANIFEST: OnceLock<Option<WasmSplitManifest>> =\n        OnceLock::new();\n\n    if let Some(splits) = SPLIT_MANIFEST.get_or_init(|| {\n        let root = root.clone().unwrap_or_default();\n\n        let (wasm_split_js, wasm_split_manifest) = if options.hash_files {\n            let hash_path = std::env::current_exe()\n                .map(|path| {\n                    path.parent().map(|p| p.to_path_buf()).unwrap_or_default()\n                })\n                .unwrap_or_default()\n                .join(options.hash_file.as_ref());\n            let hashes = std::fs::read_to_string(&hash_path)\n                .expect(\"failed to read hash file\");\n\n            let mut split =\n                \"__wasm_split.______________________.js\".to_string();\n            let mut manifest = \"__wasm_split_manifest.json\".to_string();\n            for line in hashes.lines() {\n                let line = line.trim();\n                if !line.is_empty() {\n                    if let Some((file, hash)) = line.split_once(':') {\n                        if file == \"manifest\" {\n                            manifest.clear();\n                            manifest.push_str(\"__wasm_split_manifest.\");\n                            manifest.push_str(hash.trim());\n                            manifest.push_str(\".json\");\n                        }\n                        if file == \"split\" {\n                            split.clear();\n                            split.push_str(\"__wasm_split.\");\n                            split.push_str(hash.trim());","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/leptos-rs/leptos/blob/32d20f6c9d517451d77beb68d88c7716823dac41/leptos/src/hydration/mod.rs#L55-L91","documentation":"In HydrationScripts, when a hash_file is configured, leptos reads the file (site-root dir joined with options.hash_file) via std::fs::read_to_string and unwraps with expect(\"failed to read hash file\"). The panic means the configured hash file is missing or unreadable at the joined path. It only runs when hash_file is set in env options.","triggerScenarios":"Using HydrationScripts with the hash_file option set while the file at {site_dir}/{hash_file} does not exist, or the binary's cwd differs from the site root so the relative join resolves elsewhere.","commonSituations":"Deploying the server binary without bundling the .hash / wasm-split hash file; running the server from a different working directory than in dev; hash_file path configured as absolute but joined onto site_dir incorrectly; a build that never generated hashes because wasm-split was disabled.","solutions":["Ensure the hash file named by hash_file exists under the configured site root directory before starting the server.","Run the binary from the directory containing the hash file, or set the site-root env option to the correct absolute path.","Copy the hash file in your deploy artifact/build script (it is emitted alongside the wasm-split output).","If you do not use wasm splitting, remove the hash_file option so this code path is skipped."],"exampleFix":"// before\noptions.hash_file = Some(\"dist/hash.txt\".into()); // file never generated\n// after\ncargo leptos build # generates dist/hash.txt, or unset hash_file when unused\n","handlingStrategy":"validation","validationCode":"let p = std::path::Path::new(&site_root).join(hash_file);\nassert!(p.is_file(), \"hash file missing at {}\", p.display());\nstd::fs::read_to_string(&p).expect(\"hash file unreadable\");\n","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Bundle the hash file with the server deploy artifact","Point LEPTOS_SITE_ROOT at the directory that actually contains build outputs","Start the binary from a known cwd or use absolute site-root paths","Add a startup health check that reads the hash file before serving"],"tags":["leptos","hydration","filesystem","panics"],"backgroundTag":"missing-file","analyzedSha":"32d20f6c9d517451d77beb68d88c7716823dac41","analyzedAt":"2026-09-01T18:55:42.580Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T01:17:15.007Z"}