{"record":{"id":"24537c6405f28e6f","repo":"santifer/career-ops","slug":"the-published-index-exceeds-max-index-bytes-byt-24537c","errorCode":null,"errorMessage":"the published index exceeds ${MAX_INDEX_BYTES} bytes: ${url}","messagePattern":"the published index exceeds (.+?) bytes: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"plugins/h1b-sponsor/install-h1b-index.mjs","lineNumber":180,"sourceCode":"    // below turn it into the ordinary failure it is. once(out, 'drain') needs\n    // no extra wiring, it already rejects when 'error' fires mid-wait.\n    let writeError = null;\n    out.on('error', err => { writeError = err; });\n    const reader = res.body.getReader();\n    let total = 0;\n    try {\n      for (;;) {\n        if (writeError) {\n          await reader.cancel().catch(() => {});\n          throw writeError;\n        }\n        const { done, value } = await reader.read();\n        if (done) break;\n        if (!value) continue;\n        total += value.byteLength;\n        if (total > MAX_INDEX_BYTES) {\n          await reader.cancel().catch(() => {});\n          throw new Error(`the published index exceeds ${MAX_INDEX_BYTES} bytes: ${url}`);\n        }\n        hash.update(value);\n        // Respect backpressure: an 8 MiB body written without it queues the\n        // whole file in memory, which is the thing streaming was for.\n        if (!out.write(value)) await once(out, 'drain');\n      }\n    } finally {\n      await new Promise(resolve => out.end(resolve));\n    }\n    // end() above flushes the tail, so a failure during that flush, or one\n    // that raced the final read, is only visible here. The digest must not\n    // vouch for bytes that never landed on disk.\n    if (writeError) throw writeError;\n    return { digest: hash.digest('hex'), bytes: total };\n  });\n}\n\n/**","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/santifer/career-ops/blob/aac998c7ed7248ea853b720ceeb1fdbeb322fc5d/plugins/h1b-sponsor/install-h1b-index.mjs#L162-L198","documentation":"downloadAsset throws this when the streamed body's accumulated byte count exceeds MAX_INDEX_BYTES, even though no (or a lying) content-length header declared it. It enforces the size cap mid-stream, cancelling the reader before discarding the partial file.","triggerScenarios":"During the reader.read() loop in downloadAsset, total (sum of chunk byteLengths) exceeds MAX_INDEX_BYTES. Triggered when the server omits content-length (chunked encoding) or lies about it, and the actual body is oversized.","commonSituations":"A chunked-transfer response from a misconfigured or malicious mirror; upstream republishes a far larger index without updating the cap; a redirect chain ends at the wrong (huge) file.","solutions":["Confirm the download URL serves the genuine index; a mirror or proxy may be serving different content.","If the official index legitimately grew, raise MAX_INDEX_BYTES in the plugin to the new bound.","Retry against the default endpoint to rule out a tampered custom asset source."],"exampleFix":"null","handlingStrategy":"validation","validationCode":"const head = await fetch(url, { method: 'HEAD' });\nconst len = Number(head.headers.get('content-length'));\nconsole.log(`expected index size: ${Number.isFinite(len) ? len + ' bytes' : 'unknown (chunked)'}`);","typeGuard":null,"tryCatchPattern":"try {\n  await installIndex();\n} catch (e) {\n  if (e.message.includes('exceeds') && e.message.includes('bytes')) {\n    console.error('Streamed body exceeded the cap mid-download; verify the mirror/endpoint integrity.');\n  }\n}","preventionTips":["Avoid untrusted mirrors/proxies for the index download.","Re-check the official index size when the plugin version changes.","Prefer endpoints that emit an accurate content-length header so the pre-flight cap (error 161) fires instead."],"tags":["streaming","size-limit","download"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"aac998c7ed7248ea853b720ceeb1fdbeb322fc5d","analyzedAt":"2026-09-16T06:35:29.214Z","contentChangedAt":"2026-09-16T06:35:29.214Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}