{"record":{"id":"196d25fcd1e88c4e","repo":"DioxusLabs/dioxus","slug":"failed-to-write-js-module","errorCode":null,"errorMessage":"failed to write js module","messagePattern":"failed to write js module","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/wasm-split/wasm-split-cli/src/main.rs","lineNumber":66,"sourceCode":"    tracing::info!(\"Building split module\");\n\n    let module = wasm_split_cli::Splitter::new(&original, &bindgened).unwrap();\n\n    let mut chunks = module.emit().unwrap();\n\n    // Write out the main module\n    tracing::info!(\n        \"Writing main module to {}\",\n        args.out_dir.join(\"main.wasm\").display()\n    );\n    std::fs::write(args.out_dir.join(\"main.wasm\"), &chunks.main.bytes).unwrap();\n\n    // Write the js module\n    std::fs::write(\n        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() {","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/DioxusLabs/dioxus/blob/393d190a801ccb441d41923e232289b4f8a5c669/packages/wasm-split/wasm-split-cli/src/main.rs#L48-L84","documentation":"After emitting the split modules, the CLI writes the JS loader glue `__wasm_split.js` into out_dir via `std::fs::write(...).expect(\"failed to write js module\")`. Because `main.wasm` was written to the same directory moments earlier, failing here usually means the environment changed mid-run or this particular write was rejected: the disk filled up, the directory was deleted or locked by another process, or the filesystem errored.","triggerScenarios":"Disk (or inode) exhaustion between the main.wasm write and the glue write; a concurrent build/watch process deleting or recreating out_dir while split is writing; antivirus or file-locking software quarantining the newly created .js file on Windows; out_dir on a flaky network mount (NFS/SMB) returning EIO.","commonSituations":"Parallel CI jobs or a `dx` watch process sharing one output directory; Docker builds hitting layer/inode limits; corporate endpoint protection locking freshly written files.","solutions":["Check the OS error text accompanying the panic; if ENOSPC, free disk space (`df -h`) and re-run","Make sure no other process (watch mode, parallel CI step) writes to or deletes out_dir while split runs - serialize the build steps","Move out_dir onto a local filesystem instead of a network mount","On Windows, exclude the build directory from antivirus scanning or pause the lock"],"exampleFix":"# before: split and e2e test race on the same dist dir, one write fails\nwasm-split-cli split app.wasm bg.wasm dist & run-e2e dist &\n# after: serialize the steps so split finishes first\nwasm-split-cli split app.wasm bg.wasm dist && run-e2e dist","handlingStrategy":"validation","validationCode":"df -h . | awk 'NR==2 && $5+0 > 90 { print \"disk nearly full\"; exit 1 }'\nflock dist.lock wasm-split-cli split app.wasm bg.wasm dist  # serialize all writers of dist","typeGuard":null,"tryCatchPattern":"if ! wasm-split-cli split app.wasm bg.wasm dist; then echo \"split failed mid-write (exit $?) - likely ENOSPC, a lock, or a concurrent writer\" >&2; exit 1; fi","preventionTips":["Keep exactly one writer per output directory; serialize split and downstream steps with a lock or && chaining","Fail CI when disk usage crosses a threshold before the build, not after writes start failing","Write outputs to local scratch space and copy artifacts afterwards, avoiding NFS/SMB out dirs","Exclude build directories from antivirus scanning on Windows"],"tags":["wasm-split","cli","io","disk-full","concurrency","windows"],"backgroundTag":null,"analyzedSha":"393d190a801ccb441d41923e232289b4f8a5c669","analyzedAt":"2026-08-16T11:27:45.815Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}