{"record":{"id":"b2c40c64bf686b67","repo":"spacedriveapp/spacedrive","slug":"failed-to-write-chunk-data","errorCode":null,"errorMessage":"Failed to write chunk data: {}","messagePattern":"Failed to write chunk data: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"core/src/ops/files/copy/strategy.rs","lineNumber":1221,"sourceCode":"\t\t\tcrate::service::network::protocol::file_transfer::FileTransferMessage::FileChunk {\n\t\t\t\ttransfer_id,\n\t\t\t\tchunk_index,\n\t\t\t\tdata: encrypted_data,\n\t\t\t\tnonce,\n\t\t\t\tchunk_checksum: *chunk_checksum.as_bytes(),\n\t\t\t};\n\n\t\tlet message_data = rmp_serde::to_vec(&chunk_message)?;\n\n\t\tsend_stream.write_u8(0).await?;\n\t\tsend_stream\n\t\t\t.write_all(&(message_data.len() as u32).to_be_bytes())\n\t\t\t.await\n\t\t\t.map_err(|e| anyhow::anyhow!(\"Failed to write message length: {}\", e))?;\n\t\tsend_stream\n\t\t\t.write_all(&message_data)\n\t\t\t.await\n\t\t\t.map_err(|e| anyhow::anyhow!(\"Failed to write chunk data: {}\", e))?;\n\t\tsend_stream\n\t\t\t.flush()\n\t\t\t.await\n\t\t\t.map_err(|e| anyhow::anyhow!(\"Failed to flush stream: {}\", e))?;\n\n\t\tfile_transfer_protocol.record_chunk_received(\n\t\t\t&transfer_id,\n\t\t\tchunk_index,\n\t\t\tbytes_read as u64,\n\t\t)?;\n\n\t\tbytes_transferred += bytes_read as u64;\n\t\tif let Some(callback) = progress_callback {\n\t\t\tcallback(bytes_transferred, total_size);\n\t\t}\n\n\t\tchunk_index += 1;\n","sourceCodeStart":1203,"sourceCodeEnd":1239,"githubUrl":"https://github.com/spacedriveapp/spacedrive/blob/6dfeccf2113039e35f2ce735f945e70dc3e4ea45/core/src/ops/files/copy/strategy.rs#L1203-L1239","documentation":"The serialized chunk payload (rmp-encoded chunk message) could not be written to the send stream. Same failure class as the length-prefix write, but failing mid-payload indicates an abrupt reset (stream or connection error) rather than a between-chunks disconnect. The transfer aborts at the current chunk.","triggerScenarios":"Peer resets the stream while the payload write is in flight; connection-level error (timeout, path change) surfacing during a large write; send buffer invalidated by connection close.","commonSituations":"Peer application closed the stream abruptly, QUIC idle timeout exceeded on slow links, abrupt network transitions such as Wi-Fi to cellular.","solutions":["Retry the copy job from its recorded chunk state","Inspect peer logs for why the receive side stopped (disk full, panic, restart)","On slow links, verify keep-alive and idle settings suffice for the transfer duration","Rule out middleboxes interfering with long-lived UDP flows"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// A mid-payload reset kills the whole stream; rerun the transfer from its chunk state.\nif let Err(ref e) = stream_file_data(/* ... */).await {\n    if e.to_string().contains(\"chunk data\") {\n        tracing::warn!(error = %e, \"stream reset mid-chunk, retrying transfer\");\n        tokio::time::sleep(std::time::Duration::from_secs(2)).await;\n        return stream_file_data(/* ... */).await;\n    }\n    return Err(e.clone());\n}","preventionTips":["Stabilize the network path for the transfer duration","Watch peer receive-side logs for the originating reset","Avoid mobile or switching networks for large pushes"],"tags":["network","file-transfer","quic","streaming"],"backgroundTag":null,"analyzedSha":"6dfeccf2113039e35f2ce735f945e70dc3e4ea45","analyzedAt":"2026-08-16T11:26:17.074Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}