zed-industries/zed · error · anyhow::Error
downloaded extension size {actual_len} does not match conten
Error message
downloaded extension size {actual_len} does not match content length {content_length} What it means
When downloading an extension archive, the host records the Content-Length header (if parseable), streams the body to completion, and then compares the received byte count against it. A mismatch means the body was truncated or altered in transit, and it bails before attempting gzip decompression so the corrupt tarball never reaches disk.
Source
Thrown at crates/extension_host/src/extension_host.rs:822
.context("error reading extensions")?;
if response.status().is_client_error() {
let text = String::from_utf8_lossy(body.as_slice());
bail!(
"status error {}, response: {text:?}",
response.status().as_u16()
);
}
let mut response: GetExtensionsResponse = serde_json::from_slice(&body)?;
response
.data
.retain(|extension| !SUPPRESSED_EXTENSIONS.contains(extension.id.as_ref()));
Ok(response.data)
})
}
pub fn install_extension(
&mut self,
extension_id: Arc<str>,
version: Arc<str>,
cx: &mut Context<Self>,
) {
self.install_or_upgrade_extension(extension_id, version, ExtensionOperation::Install, cx)
.detach_and_log_err(cx);
}
fn install_or_upgrade_extension_at_endpoint(
&mut self,
extension_id: Arc<str>,
url: Url,
operation: ExtensionOperation,
cx: &mut Context<Self>,
) -> Task<Result<()>> {View on GitHub (pinned to 9d272b0363)
Solutions
- Retry the download — transient truncation is the most common cause.
- If it persists, verify with `curl -sI <archive-url>` that Content-Length matches what a full `curl -o` download produces.
- Disable or bypass HTTP-manipulating proxies/VPN and retry.
- Report to the extension publisher/host if the server itself advertises a wrong Content-Length.
Defensive patterns
Strategy: retry
Try / catch
let tar_gz_bytes = retry_with_backoff(3, || async {
let bytes = download_extension(&client, url).await?;
if let Some(expected) = content_length {
anyhow::ensure!(bytes.len() == expected, "truncated download");
}
Ok(bytes)
}).await?; Prevention
- Validate byte count against Content-Length immediately after streaming, before decompression.
- Retry truncated downloads with exponential backoff; most mismatches are transient.
- Avoid HTTP-transforming proxies for large archive downloads; verify sizes with curl when debugging.
When it happens
Trigger: Connection reset or timeout mid-download; a proxy or antivirus rewriting the body (injecting an error page); server sending a stale/incorrect Content-Length; transparent decompression by an intermediary changing the byte count.
Common situations: Flaky Wi-Fi/VPN links dropping large archive downloads; corporate TLS-inspection proxies; CDN inconsistencies where the header doesn't match the served object; retries after partial failures.
Related errors
- origin/main tip {main_sha[:12]} unavailable locally after fe
- git merge-base --is-ancestor failed
- WSAStartup failed: {}
- Could not fetch Protected Resource Metadata for {}
- Could not fetch Authorization Server Metadata for {}
AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-08-20).
Data as JSON: /api/errors/2e3216731666eaed.
Report an issue: GitHub.