spacedriveapp/spacedrive · error · anyhow::Error

Failed to deserialize sync response: {}

Error message

Failed to deserialize sync response: {}

What it means

The response bytes were read but did not deserialize as a SyncMessage. In this protocol it almost always means version skew - the peer serialized an enum variant or field layout your build does not know - or the payload was truncated or garbled in transit.

Source

Thrown at core/src/service/network/protocol/sync/transport.rs:211

				.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",
					target_device
				))
			}
		};

		// Deserialize response
		let response: SyncMessage = serde_json::from_slice(&resp_buf)
			.map_err(|e| anyhow::anyhow!("Failed to deserialize sync response: {}", e))?;

		debug!(
			device_uuid = %target_device,
			response_type = ?std::mem::discriminant(&response),
			"Received sync response"
		);

		Ok(response)
	}

	/// Get list of currently connected sync partner devices
	///
	/// Returns device UUIDs that are both:
	/// - Registered in DeviceRegistry (paired)
	/// - Currently have an active connection
	///
	/// Note: This doesn't query the sync_partners table - that's the caller's responsibility.
	/// We just report which devices are network-reachable right now.

View on GitHub (pinned to 6dfeccf211)

Solutions

  1. Upgrade both devices to the same version
  2. Log the serde error plus the first bytes of the payload to identify the offending variant
  3. Keep serde enum tags stable across releases and tolerate unknown variants where possible
  4. Add a protocol version to the handshake or ALPN so mismatches fail fast
Defensive patterns

Strategy: try-catch

Type guard

fn is_deserialize_failure(err: &anyhow::Error) -> bool {
    err.to_string().contains("Failed to deserialize sync response")
}

Try / catch

match net.send_sync_request(device, request).await {
    Ok(resp) => { /* ... */ }
    Err(e) if is_deserialize_failure(&e) => {
        // almost always version skew: do not retry; surface 'incompatible version' to the user
        Err(anyhow::anyhow!("device {} runs an incompatible version", device))
    }
    Err(e) => Err(e),
}

Prevention

When it happens

Trigger: Two devices running different spacedrive versions with changed SyncMessage enums; renamed or removed serde tags; truncation from a mid-body failure; peer speaking a different framing on the same ALPN.

Common situations: Upgrading one machine but not the other; refactors that rename enum variants or restructure payloads without compatibility handling.

Related errors


AI-assisted analysis of spacedriveapp/spacedrive@6dfeccf211 (2026-08-16). Data as JSON: /api/errors/ffcd607186731fdc. Report an issue: GitHub.