spacedriveapp/spacedrive · error · anyhow::Error
Failed to open stream: {}
Error message
Failed to open stream: {} What it means
The QUIC connection was established but connection.open_bi() failed, so no bidirectional stream could be opened for the chunk frames. This means the connection died between connect() and stream open, or the peer is not accepting streams for this protocol. The transfer aborts before any file data is sent.
Source
Thrown at core/src/ops/files/copy/strategy.rs:1142
.endpoint()
.ok_or_else(|| anyhow::anyhow!("Networking endpoint not available"))?;
ctx.log(format!(
"Opening persistent connection to node {} (device {}) for file transfer",
node_id, destination_device_id
));
let node_addr = iroh::EndpointAddr::new(node_id);
let connection = endpoint
.connect(node_addr, b"spacedrive/filetransfer/1")
.await
.map_err(|e| anyhow::anyhow!("Failed to connect to device: {}", e))?;
// Bidirectional stream allows receiving acknowledgment after transfer completion.
let (mut send_stream, mut recv_stream) = connection
.open_bi()
.await
.map_err(|e| anyhow::anyhow!("Failed to open stream: {}", e))?;
let chunk_size = 64 * 1024u32;
let total_chunks = ((total_size + chunk_size as u64 - 1) / chunk_size as u64) as u32;
let transfer_request =
crate::service::network::protocol::file_transfer::FileTransferMessage::TransferRequest {
transfer_id,
file_metadata,
transfer_mode: crate::service::network::protocol::TransferMode::TrustedCopy,
chunk_size,
total_chunks,
destination_path: destination_path.clone(),
};
let request_data = rmp_serde::to_vec(&transfer_request)?;
ctx.log(format!(
"Sending TransferRequest for {} bytes ({} chunks) to destination: {}",View on GitHub (pinned to 6dfeccf211)
Solutions
- Retry the transfer - it opens a fresh connection
- Confirm the peer daemon runs the file transfer handler (same or newer version)
- Check peer logs for handler startup failures
- If persistent between two specific devices, re-pair them
Defensive patterns
Strategy: retry
Try / catch
// open_bi races connection teardown; one retry on a fresh connection usually clears it.
let (mut send_stream, mut recv_stream) = match connection.open_bi().await {
Ok(pair) => pair,
Err(e) => {
tracing::warn!(error = %e, "open_bi failed, reconnecting");
let connection = endpoint.connect(node_addr, alpn).await?;
connection.open_bi().await?
}
}; Prevention
- Upgrade devices together to keep protocol handlers aligned
- Avoid dispatching transfers during daemon maintenance windows
When it happens
Trigger: Connection reset immediately after the handshake; peer daemon shutting down and refusing new streams; peer lacks the file-transfer ALPN handler due to version skew; idle timeout expiring between connect and open_bi.
Common situations: Peer restarting for updates, version mismatch after one side upgraded, aggressive NAT timeouts on mobile networks.
Related errors
- Failed to write message length: {}
- Failed to write chunk data: {}
- Failed to flush stream: {}
- Failed to finish stream: {}
- Failed to open bidirectional stream: {}
AI-assisted analysis of spacedriveapp/spacedrive@6dfeccf211 (2026-08-16).
Data as JSON: /api/errors/75048d4c71deb39d.
Report an issue: GitHub.