denoland/deno · error · TypeError
Response status must not be 206
Error message
Response status must not be 206
What it means
Cache.put(request, response) rejects responses with status 206 Partial Content (spec step 6). A 206 response is the result of a Range request and represents only a fragment of the resource, so the Cache API refuses to store it.
Solutions
- Fetch the full resource (omit the Range header) before caching
- Skip caching when `response.status === 206`
- If the body is actually complete, rebuild a 200 Response around it before caching
Example fix
// before
const res = await fetch(url, { headers: { Range: "bytes=0-1023" } });
await cache.put(req, res); // 206 -> throws
// after
const res = await fetch(url); // full body
if (res.status === 200) await cache.put(req, res); Defensive patterns
Strategy: validation
Validate before calling
if (response.status === 206) {
// partial content: fetch the full resource instead of caching
} Prevention
- Do not send Range headers for resources you intend to cache
- Gate caching on response.status === 200
- Rebuild a complete 200 Response around a known-complete body before caching
When it happens
Trigger: `cache.put(req, res)` where res.status === 206, typically because the fetch sent a Range header and the origin answered with partial content.
Common situations: Media streaming or resumable-download code that fetches ranges and then tries to cache the fragment; proxies that forward Range requests.
Related errors
- Failed to receive WebAssembly content: HTTP status code
- Request method must be GET
- Request url protocol must be 'http:' or 'https:': received
- Response body is already used
- SystemTime is before unix epoch
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/acfdc6887483b66c.
Report an issue: GitHub.
Appendix: source
Thrown at ext/cache/01_cache.js:160
} else {
// Step 3.
innerRequest = toInnerRequest(new Request(request));
}
// Step 4.
const reqUrl = new URL(innerRequest.url());
if (reqUrl.protocol !== "http:" && reqUrl.protocol !== "https:") {
throw new TypeError(
`Request url protocol must be 'http:' or 'https:': received '${reqUrl.protocol}'`,
);
}
if (innerRequest.method !== "GET") {
throw new TypeError("Request method must be GET");
}
// Step 5.
const innerResponse = toInnerResponse(response);
// Step 6.
if (innerResponse.status === 206) {
throw new TypeError("Response status must not be 206");
}
// Step 7.
const varyHeader = getHeader(innerResponse.headerList, "vary");
if (varyHeader) {
const fieldValues = StringPrototypeSplit(varyHeader, ",");
for (let i = 0; i < fieldValues.length; ++i) {
const field = fieldValues[i];
if (StringPrototypeTrim(field) === "*") {
throw new TypeError("Vary header must not contain '*'");
}
}
}
// Step 8.
if (innerResponse.body !== null && innerResponse.body.unusable()) {
throw new TypeError("Response body is already used");
}
View on GitHub (pinned to 9ad36f7a2c)