{"record":{"id":"3bcf06b56dd54d3d","repo":"parcel-bundler/parcel","slug":"untarring-failed-currentheaderstart-filename","errorCode":null,"errorMessage":"untarring failed: ${currentHeaderStart}@${filename}","messagePattern":"untarring failed: (.+?)@(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/repl/SimplePackageInstaller/untar.js","lineNumber":60,"sourceCode":"      .map(c => String.fromCharCode(c))\n      .join('');\n\n    if (!filename) break;\n\n    let filesize = parseInt(\n      Array.from(\n        bufferSliceNull(\n          view,\n          currentHeaderStart + TAR_HEADER_OFFSETS.filesize[0],\n          TAR_HEADER_OFFSETS.filesize[1],\n        ),\n      )\n        .map(c => String.fromCharCode(c))\n        .join(''),\n      8,\n    );\n    if (isNaN(filesize)) {\n      throw new Error(`untarring failed: ${currentHeaderStart}@${filename}`);\n    }\n\n    let data = view.slice(\n      currentHeaderStart + 512,\n      currentHeaderStart + 512 + filesize,\n    );\n    files.set(filename.slice('package/'.length), data);\n\n    currentHeaderStart = roundUpToMultipleOf512(\n      currentHeaderStart + 512 + filesize,\n    );\n  }\n\n  return files;\n}\n","sourceCodeStart":42,"sourceCodeEnd":76,"githubUrl":"https://github.com/parcel-bundler/parcel/blob/59484858a1a0bcbb71f74088956bb437a2db6505/packages/dev/repl/SimplePackageInstaller/untar.js#L42-L76","documentation":"Thrown by `untar` when the parsed `filesize` field of a tar header is `NaN`, meaning the octal-ascii size field at the current header offset is empty or non-numeric. This indicates the gzip/tar payload is corrupt, truncated, or not actually an npm package tarball.","triggerScenarios":"The ArrayBuffer passed to `untar` is not a gzipped tar; the gzip was partially downloaded (truncation); decompression produced garbage; tar header offsets drifted due to an earlier misparse.","commonSituations":"Network truncation of a tarball fetch; CDN returned an HTML error page that was fed in as the tarball; version skew between pako inflate and the payload; concurrent modification of the buffer.","solutions":["Re-fetch the tarball — truncation/corruption is usually transient.","Confirm the upstream fetch (error 104) actually succeeded and returned a gzip body.","Check the `currentHeaderStart@filename` in the message: offset 0 with a garbage filename means the whole payload is wrong; a later offset means mid-tar corruption.","If reproducible for one package, the registry tarball itself may be bad — try a different version."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"function looksLikeGzip(buf) {\n  return buf && buf.byteLength >= 2 && new Uint8Array(buf)[0] === 0x1f && new Uint8Array(buf)[1] === 0x8b;\n}","typeGuard":null,"tryCatchPattern":"try { files = untar(buffer); }\ncatch (e) {\n  if (/untarring failed/.test(e.message)) { /* refetch tarball, retry once */ }\n  else throw e;\n}","preventionTips":["Validate the gzip magic bytes before untarring.","Re-fetch on untar failure rather than trusting the first download.","Treat a non-gzip body as an upstream fetch error (HTML error page)."],"tags":["untar","tarball","corruption","repl"],"backgroundTag":null,"analyzedSha":"59484858a1a0bcbb71f74088956bb437a2db6505","analyzedAt":"2026-08-13T04:06:35.925Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}