spacedriveapp/spacedrive · error · anyhow::Error
Failed to read response length: {}
Error message
Failed to read response length: {} What it means
Reading the 4-byte response length header failed inside the 60-second timeout window. The peer closed the stream without sending a response (clean EOF or stream reset), or the connection was lost before any response bytes arrived. The request reached a peer that did not answer.
Source
Thrown at core/src/service/network/transports/sync.rs:282
send.write_all(&len.to_be_bytes())
.await
.map_err(|e| anyhow::anyhow!("Failed to send length: {}", e))?;
send.write_all(&req_bytes)
.await
.map_err(|e| anyhow::anyhow!("Failed to send request: {}", e))?;
// Properly close send stream
send.finish()
.map_err(|e| anyhow::anyhow!("Failed to finish stream: {}", e))?;
debug!("Sync request sent, waiting for response...");
// Read response with timeout
let result = timeout(Duration::from_secs(60), async {
let mut len_buf = [0u8; 4];
recv.read_exact(&mut len_buf)
.await
.map_err(|e| anyhow::anyhow!("Failed to read response length: {}", e))?;
let resp_len = u32::from_be_bytes(len_buf) as usize;
debug!("Receiving sync response of {} bytes", resp_len);
let mut resp_buf = vec![0u8; resp_len];
recv.read_exact(&mut resp_buf)
.await
.map_err(|e| anyhow::anyhow!("Failed to read response: {}", e))?;
Ok::<_, anyhow::Error>(resp_buf)
})
.await;
let resp_buf = match result {
Ok(Ok(buf)) => buf,
Ok(Err(e)) => return Err(e),
Err(_) => {
return Err(anyhow::anyhow!(
"Sync request timed out after 60s - peer {} not responding",View on GitHub (pinned to 6dfeccf211)
Solutions
- Check the peer's logs for a handler error or panic corresponding to the request
- Verify both peers run compatible sync protocol versions and update them to match
- Retry once; if the peer consistently closes without responding, mark it unavailable for this session
Defensive patterns
Strategy: retry
Try / catch
match recv.read_exact(&mut len_buf).await {
Err(_) => {
// peer closed without responding: mark partner suspect, retry once, then back off
}
Ok(_) => { /* continue */ }
} Prevention
- Keep both peers on compatible sync protocol versions
- Log peer-side handler errors so closes without response are diagnosable
- Use a per-partner failure counter to stop retrying a silent peer
When it happens
Trigger: Peer accepted the stream but its sync handler errored and closed; peer process crashed mid-exchange; version skew where the peer does not implement the length-prefixed response protocol for this message type.
Common situations: Mixed versions during rollout; peers under load rejecting streams; handler panics on unexpected message variants.
Related errors
- Failed to read response length: {}
- Failed to read response: {}
- Failed to read response: {}
- Failed to open bidirectional stream: {}
- Failed to send length: {}
AI-assisted analysis of spacedriveapp/spacedrive@6dfeccf211 (2026-08-16).
Data as JSON: /api/errors/5b2b2748a175583d.
Report an issue: GitHub.