{"record":{"id":"6c68b9d24817ebab","repo":"spacedriveapp/spacedrive","slug":"failed-to-read-response-length","errorCode":null,"errorMessage":"Failed to read response length: {}","messagePattern":"Failed to read response length: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"core/src/service/network/protocol/sync/transport.rs","lineNumber":184,"sourceCode":"\t\tlet len = req_bytes.len() as u32;\n\t\tsend.write_all(&len.to_be_bytes())\n\t\t\t.await\n\t\t\t.map_err(|e| anyhow::anyhow!(\"Failed to send length: {}\", e))?;\n\t\tsend.write_all(&req_bytes)\n\t\t\t.await\n\t\t\t.map_err(|e| anyhow::anyhow!(\"Failed to send request: {}\", e))?;\n\n\t\t// Properly close send stream\n\t\tsend.finish()\n\t\t\t.map_err(|e| anyhow::anyhow!(\"Failed to finish stream: {}\", e))?;\n\n\t\tdebug!(\"Sync request sent, waiting for response...\");\n\n\t\t// Read response with timeout\n\t\tlet result = timeout(Duration::from_secs(60), async {\n\t\t\tlet mut len_buf = [0u8; 4];\n\t\t\trecv.read_exact(&mut len_buf).await.map_err(|e| {\n\t\t\t\tanyhow::anyhow!(\"Failed to read response length: {}\", e)\n\t\t\t})?;\n\t\t\tlet resp_len = u32::from_be_bytes(len_buf) as usize;\n\n\t\t\tdebug!(\"Receiving sync response of {} bytes\", resp_len);\n\n\t\t\tlet mut resp_buf = vec![0u8; resp_len];\n\t\t\trecv.read_exact(&mut resp_buf)\n\t\t\t\t.await\n\t\t\t\t.map_err(|e| anyhow::anyhow!(\"Failed to read response: {}\", e))?;\n\t\t\tOk::<_, anyhow::Error>(resp_buf)\n\t\t})\n\t\t.await;\n\n\t\tlet resp_buf = match result {\n\t\t\tOk(Ok(buf)) => buf,\n\t\t\tOk(Err(e)) => return Err(e),\n\t\t\tErr(_) => {\n\t\t\t\treturn Err(anyhow::anyhow!(","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/spacedriveapp/spacedrive/blob/6dfeccf2113039e35f2ce735f945e70dc3e4ea45/core/src/service/network/protocol/sync/transport.rs#L166-L202","documentation":"recv.read_exact for the 4-byte response length failed in send_sync_request. read_exact returns UnexpectedEof when the peer closes the stream without responding, and a connection error when the link drops - in both cases the peer never answered the request.","triggerScenarios":"Peer accepted the request but crashed or closed before responding; peer does not implement the length-prefixed response framing; connection lost while awaiting the response.","commonSituations":"Peer daemon crash mid-handler; version skew where the peer silently drops the request; peer killed by the OS under memory pressure.","solutions":["Check peer logs: did its sync handler receive and process the request?","Verify both sides use the same length-prefixed bidirectional framing","Retry once on a new connection","Confirm protocol version compatibility between the two devices"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"Err(e) if e.to_string().contains(\"Failed to read response length\") => {\n    // peer never answered: verify peer handler ran, then retry once on a new connection\n    check_peer_logs(device);\n    retry_request_on_fresh_connection(device, request).await\n}","preventionTips":["Keep peers on compatible versions so handlers always respond","Retry once on a fresh connection before marking the peer broken","Log which request type produced the silent peer so peers can be debugged"],"tags":["network","iroh","quic","protocol","sync","rust"],"backgroundTag":null,"analyzedSha":"6dfeccf2113039e35f2ce735f945e70dc3e4ea45","analyzedAt":"2026-08-16T11:26:17.074Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}