{"record":{"id":"569f97be6ed3ef82","repo":"DioxusLabs/dioxus","slug":"failed-to-write-chunk","errorCode":null,"errorMessage":"failed to write chunk","messagePattern":"failed to write chunk","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/wasm-split/wasm-split-cli/src/main.rs","lineNumber":81,"sourceCode":"        args.out_dir.join(\"__wasm_split.js\"),\n        emit_js(&chunks.chunks, &chunks.modules),\n    )\n    .expect(\"failed to write js module\");\n\n    for (idx, chunk) in chunks.chunks.iter().enumerate() {\n        tracing::info!(\n            \"Writing chunk {} to {}\",\n            idx,\n            args.out_dir\n                .join(format!(\"chunk_{}_{}.wasm\", idx, chunk.module_name))\n                .display()\n        );\n        std::fs::write(\n            args.out_dir\n                .join(format!(\"chunk_{}_{}.wasm\", idx, chunk.module_name)),\n            &chunk.bytes,\n        )\n        .expect(\"failed to write chunk\");\n    }\n\n    for (idx, module) in chunks.modules.iter_mut().enumerate() {\n        tracing::info!(\n            \"Writing module {} to {}\",\n            idx,\n            args.out_dir\n                .join(format!(\n                    \"module_{}_{}.wasm\",\n                    idx,\n                    module.component_name.as_ref().unwrap()\n                ))\n                .display()\n        );\n        std::fs::write(\n            args.out_dir.join(format!(\n                \"module_{}_{}.wasm\",\n                idx,","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/DioxusLabs/dioxus/blob/393d190a801ccb441d41923e232289b4f8a5c669/packages/wasm-split/wasm-split-cli/src/main.rs#L63-L99","documentation":"Each split chunk is written as `chunk_<idx>_<module_name>.wasm` in out_dir, and a failed `std::fs::write` panics with \"failed to write chunk\". Besides ordinary IO problems (disk full, permissions revoked), the filename embeds the chunk's module_name, so a name containing characters invalid in filenames on the target OS - or a combined name exceeding the filesystem's 255-byte component limit - makes exactly this write fail while earlier writes succeeded.","triggerScenarios":"A chunk module_name containing `/`, `\\`, or characters like `:` that are invalid on Windows; an out_dir path plus generated name exceeding NAME_MAX; ENOSPC or revoked permissions after the earlier main.wasm and JS glue writes consumed the remaining space or the lock changed.","commonSituations":"Cross-platform builds where a name is legal on Linux but invalid on Windows/macOS; deeply nested Rust module paths producing very long generated filenames; Docker inode exhaustion mid-build.","solutions":["Read the tracing line printed just above the panic - it shows the exact target path; check that filename for invalid characters or excessive length","Free disk space or restore write permissions on out_dir, then re-run","Shorten the out_dir path so the combined generated filename fits within 255 bytes","Rename the offending Rust module (or patch/report wasm-split's name sanitization) if the module_name is not filename-safe on the target OS"],"exampleFix":"# before: deep out_dir + long module name exceeds NAME_MAX on this filesystem\nwasm-split-cli split app.wasm bg.wasm /very/long/build/prefix/dist\n# after: shorter output root (and/or rename the deep Rust module)\nwasm-split-cli split app.wasm bg.wasm dist","handlingStrategy":"validation","validationCode":"# before invoking, confirm the target filesystem accepts the generated names\nname_max=$(stat -f -c %l dist 2>/dev/null || stat -f -l dist 2>/dev/null || echo 255)\nfind dist -name 'chunk_*' -printf '%f\\n' 2>/dev/null | awk -v m=\"$name_max\" 'length($0) >= m { print \"filename too long: \" $0; exit 1 }'","typeGuard":null,"tryCatchPattern":"if ! wasm-split-cli split app.wasm bg.wasm dist; then echo \"chunk write failed (exit $?) - check the logged chunk path for invalid characters/length\" >&2; exit 1; fi","preventionTips":["Enable the CLI's debug logging (it logs each target path before writing) and eyeball generated chunk names once per build","Prefer short out_dir roots so generated names stay under NAME_MAX","Build on the same OS you deploy from, or verify module names are filename-safe on Windows/macOS","Keep free disk headroom so late writes do not fail after early ones succeed"],"tags":["wasm-split","cli","io","filename","cross-platform","panic"],"backgroundTag":null,"analyzedSha":"393d190a801ccb441d41923e232289b4f8a5c669","analyzedAt":"2026-08-16T11:27:45.815Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}