denoland/deno · error · TypeError
Response status must not be 206
Error message
Response status must not be 206
What it means
Step 6 of Cache.put(): a 206 Partial Content response must not be cached, because a later cache match would serve an arbitrary byte range instead of the full representation.
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 89f33cbef2)
Solutions
- Do not send a Range header on requests whose responses you intend to cache — fetch the full body.
- Skip put() when response.status === 206.
Example fix
// before
await cache.put(req, res); // res.status === 206
// after
if (res.status !== 206) {
await cache.put(req, res);
} Defensive patterns
Strategy: validation
Validate before calling
if (response.status !== 206) {
await cache.put(request, response);
} Try / catch
try { await cache.put(req, res); } catch (e) { if (e instanceof TypeError) { /* partial content: not cacheable */ } else throw e; } Prevention
- Do not send Range headers on requests whose responses will be cached.
- Treat any non-200-299 (especially 206) response as non-cacheable in your caching wrapper.
When it happens
Trigger: Caching a response produced from a Range request (response.status === 206).
Common situations: Media players, resumable downloaders, and range-streaming clients that also try to populate the Cache API.
Related errors
- BenchContext::end() has already been invoked
- Object is not a valid image or a path to an image. `Deno.jup
- Request url protocol must be 'http:' or 'https:': received '
- Request method must be GET
- Vary header must not contain '*'
AI-assisted analysis of denoland/deno@89f33cbef2 (2026-08-16).
Data as JSON: /api/errors/acfdc6887483b66c.
Report an issue: GitHub.