wasmerio/wasmer · error
unsupported content-encoding: {other}
Error message
unsupported content-encoding: {other} What it means
decode_response_body accepts only a known set of Content-Encoding values (gzip, deflate/br/zstd variants, and 'identity'); any other encoding token reaches the catch-all arm and aborts the package download. The library refuses to guess how to decode an encoding it doesn't implement.
Source
Thrown at lib/wasix/src/runtime/package_loader/builtin_loader.rs:398
reader = Box::new(flate2::read::GzDecoder::new(reader));
}
"zstd" => {
#[cfg(not(target_arch = "wasm32"))]
{
reader = Box::new(
zstd::stream::read::Decoder::new(reader)
.context("failed to initialize zstd decoder")?,
);
}
#[cfg(target_arch = "wasm32")]
{
// NOTE: in browsers this code will not be hit because
// the fetch API automatically handles content decoding.
bail!("zstd content-encoding is not supported on wasm32");
}
}
"identity" => {}
other => bail!("unsupported content-encoding: {other}"),
}
}
let mut decoded = Vec::new();
reader
.read_to_end(&mut decoded)
.context("failed to decode response body")?;
Ok(decoded)
}
}
impl Default for BuiltinPackageLoader {
fn default() -> Self {
BuiltinPackageLoader::new()
}
}
#[async_trait::async_trait]View on GitHub (pinned to 8c4b9ee9d3)
Solutions
- Inspect the response's Content-Encoding header value and fix the server/proxy to send an encoding the loader supports (gzip, zstd, br, or identity — ideally just 'identity' for package downloads)
- Disable content-transform/compression middleware for the registry endpoint (e.g. CDN 'auto-compress' off, proxy response-encoding filter bypassed)
- Ensure only a single encoding token is sent — if the origin plus proxy each compress, disable one layer to avoid 'gzip, br' style values
- As a client workaround, point the loader at a mirror that serves uncompressed (Content-Encoding: identity) package artifacts
Example fix
// before: proxy stacking encodings // Content-Encoding: gzip, br -> bail! unsupported // after: single pass at the edge // Content-Encoding: identity (or gzip only) // nginx: // gzip off; # origin already serves plain artifacts
Defensive patterns
Strategy: try-catch
Validate before calling
// validate encoding before handing the response to the loader
fn validate_content_encoding(header: Option<&str>) -> Result<(), String> {
const KNOWN: &[&str] = &[
"identity", "gzip", "x-gzip", "deflate", "br", "zstd",
];
let enc = header.unwrap_or("identity");
if enc.contains(',') {
return Err(format!("stacked content-encoding not supported: {enc}"));
}
if !KNOWN.contains(&enc.trim().to_ascii_lowercase().as_str()) {
return Err(format!("unsupported content-encoding: {enc}"));
}
Ok(())
} Type guard
fn is_supported_encoding(header: Option<&str>) -> bool {
const KNOWN: &[&str] = &[
"identity", "gzip", "x-gzip", "deflate", "br", "zstd",
];
let enc = header.unwrap_or("identity").trim();
!enc.contains(',') && KNOWN.contains(&enc.to_ascii_lowercase().as_str())
} Try / catch
match loader.download_and_decode(url).await {
Ok(pkg) => Ok(pkg),
Err(e) if e.to_string().starts_with("unsupported content-encoding:") => {
log::warn!("{e}; retrying via uncompressed mirror");
loader.download_and_decode(identity_mirror_url(url)).await
}
Err(e) => Err(e.into()),
} Prevention
- Disable content-transform/compression middleware for package registry endpoints so responses go out identity-encoded
- Keep the encoding chain to a single hop — never let origin and proxy both compress
- Pin package downloads to mirrors you control and audit their response headers (curl -sI) in CI
- Handle 'Content-Encoding' with parameters/stacked tokens explicitly at your HTTP layer before it reaches the loader
When it happens
Trigger: A registry, mirror, or proxy responds to a package fetch with an exotic Content-Encoding header — e.g. 'zstd-raw', 'lz4', 'br; q=1' malformed values, double encodings like 'gzip, br', or a typo'd custom token — while builtin_loader streams the body.
Common situations: Corporate proxies / security appliances injecting encoding; misconfigured CDN transform rules; custom Rust-based registry emitting a novel encoding; HTTP middleware stacking multiple encodings into one header.
Related errors
- zstd content-encoding is not supported on wasm32
- Timeout while downloading response body
- Internal error: failed to resolve exported function {}: {e:?
- Internal error: Tried to import TLS symbol from module {} th
- Internal error: missing import resolution '{0}'.{1}
AI-assisted analysis of wasmerio/wasmer@8c4b9ee9d3 (2026-09-01).
Data as JSON: /api/errors/af818ed7b03cd326.
Report an issue: GitHub.