santifer/career-ops · error · Error
the index response carried no readable body
Error message
the index response carried no readable body: ${url} What it means
downloadAsset throws this when the fetch Response has no body or its body does not expose getReader(), so the index cannot be streamed. The installer requires a WHATWG-streams-compatible response body to hash-while-writing.
Solutions
- If you inject a fetchImpl, return a Response with a real ReadableStream body (e.g. new Response(readableStream)).
- Use a fetch implementation with streams support (undici / Node >= 18 built-in fetch), not a text-only polyfill.
- Do not reuse an already-consumed Response object; refetch instead.
Example fix
// before
fetchImpl: async (url) => ({ status: 200, headers: new Map(), text: async () => data })
// after
fetchImpl: async (url) => new Response(ReadableStream.from([Buffer.from(data)]), { status: 200 }) Defensive patterns
Strategy: type-guard
Validate before calling
if (typeof fetchImpl !== 'function') throw new Error('fetchImpl must be a function');
const probe = await fetchImpl(url, {});
if (!probe.body || typeof probe.body.getReader !== 'function') throw new Error('fetch impl must return a streaming Response body'); Type guard
function hasStreamBody(res) {
return !!res && !!res.body && typeof res.body.getReader === 'function';
} Try / catch
try {
await installIndex();
} catch (e) {
if (e.message.includes('no readable body')) {
console.error('Your injected fetch/polyfill lacks stream support; use undici or Node built-in fetch.');
}
} Prevention
- Test any custom fetchImpl against downloadAsset in CI before relying on it.
- Use Node >= 18 built-in fetch (undici) which always provides a ReadableStream body.
- Never reuse a consumed Response object.
When it happens
Trigger: downloadAsset's fetchImpl returns a response where res.body is null/undefined or lacks a getReader function — e.g. a stubbed fetch in tests, an undici Response consumed already, or a non-standard fetch implementation.
Common situations: Custom fetchImpl injection (tests, proxies) returning an incomplete Response mock; a fetch polyfill without stream support; calling downloadAsset twice on the same Response (body already consumed/nullified).
Related errors
- 4dayweek: invalid URL
- 4dayweek: URL must use HTTPS
- a 40-hex commit --sha is required
- apify: entry has invalid field_map. Each of title, url…
- apify: entry missing 'actor' (e.g. misceres/indeed-scraper)
AI-assisted analysis of santifer/career-ops@aac998c7ed (2026-09-16).
Data as JSON: /api/errors/3a9074c9dbea0301.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/h1b-sponsor/install-h1b-index.mjs:152
}
/**
* Stream the asset to `tmpFile`, hashing as it goes, and return the digest.
*
* Streamed rather than buffered: the body is millions of times the size of
* anything else this plugin reads, and readBoundedText's 1 MiB ceiling exists
* precisely because nothing on the API path should ever be this big. Hashing
* during the write means the file is never read a second time to verify it.
*/
async function downloadAsset(fetchImpl, url, tmpFile) {
return fetchImpl(url, { timeoutMs: ASSET_TIMEOUT_MS }, async res => {
if (res.status !== 200) throw new Error(`could not download the index (HTTP ${res.status}): ${url}`);
const declared = Number(res.headers?.get?.('content-length'));
if (Number.isFinite(declared) && declared > MAX_INDEX_BYTES) {
throw new Error(`the published index exceeds ${MAX_INDEX_BYTES} bytes (${declared}): ${url}`);
}
if (!res.body || typeof res.body.getReader !== 'function') {
throw new Error(`the index response carried no readable body: ${url}`);
}
const hash = createHash('sha256');
const out = createWriteStream(tmpFile);
// A write failure (disk full, an unwritable target) arrives as an 'error'
// event on the stream, and an EventEmitter error with no listener is an
// uncaughtException: the CLI died on a stack trace instead of returning
// the envelope, and the cleanup that removes the partial .tmp file never
// ran. Recording the error here makes the crash impossible; the checks
// below turn it into the ordinary failure it is. once(out, 'drain') needs
// no extra wiring, it already rejects when 'error' fires mid-wait.
let writeError = null;
out.on('error', err => { writeError = err; });
const reader = res.body.getReader();
let total = 0;
try {
for (;;) {
if (writeError) {View on GitHub (pinned to aac998c7ed)