{"record":{"id":"bb8b22e538a39b42","repo":"cypress-io/cypress","slug":"corrupted-download-expected-downloaded-file-to-ha-bb8b22","errorCode":null,"errorMessage":"Corrupted download\n\nExpected downloaded file to have size: ${expectedSize}\nComputed size: ${filesize}","messagePattern":"Corrupted download\n\nExpected downloaded file to have size: (.+?)\nComputed size: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/lib/tasks/download.ts","lineNumber":191,"sourceCode":"    debug('only checking expected file size %d', expectedSize)\n\n    const filesize: number = await util.getFileSize(filename)\n\n    if (filesize === expectedSize) {\n      debug('downloaded file has the expected size ✅')\n\n      return\n    }\n\n    debug('raising error: file size mismatch')\n    const text = stripIndent`\n        Corrupted download\n\n        Expected downloaded file to have size: ${expectedSize}\n        Computed size: ${filesize}\n      `\n\n    throw new Error(text)\n  }\n\n  debug('downloaded file lacks checksum or size to verify')\n\n  return\n}\n\n// downloads from given url\n// return an object with\n// {filename: ..., downloaded: true}\nconst downloadFromUrl = ({ url, downloadDestination, progress, ca, version, redirectTTL = defaultMaxRedirects }: any): any => {\n  if (redirectTTL <= 0) {\n    return Promise.reject(new Error(\n      stripIndent`\n          Failed downloading the Cypress binary.\n          There were too many redirects. The default allowance is ${defaultMaxRedirects}.\n          Maybe you got stuck in a redirect loop?\n        `,","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/cypress-io/cypress/blob/0d85fdc91230885bca0a91df278312800a48b727/cli/lib/tasks/download.ts#L173-L209","documentation":"Raised by verifyDownloadedFile() when only an expected size was available (no checksum header) and the on-disk file size differs from the expected content-length/x-amz-meta-size. This is the weakest verification path: it catches truncation and concatenation but not byte-level corruption.","triggerScenarios":"`cypress install` where the CDN/mirror served a content-length but no x-amz-meta-checksum, and the written file ended up larger (e.g. proxy appended an error page) or smaller (truncated) than that length.","commonSituations":"A proxy injecting an HTML error page after a partial body; connection cut mid-stream leaving a short file; mirror that strips checksum metadata; disk-full condition truncating the write.","solutions":["Free disk space and re-run `cypress install` after removing ~/.cache/Cypress.","Bypass a misbehaving proxy/CDN by setting CYPRESS_INSTALL_BINARY to a trusted URL or local file.","If using a mirror, ensure it preserves content-length and serves the complete artifact; fall back to the default download source.","Verify network stability for large file transfers (the Cypress binary is hundreds of MB)."],"exampleFix":"# before: size mismatch on install\n# after:\nCYPRESS_INSTALL_BINARY=/path/to/verified/cypress.zip cypress install","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await cypress.install()\n} catch (e) {\n  if (e instanceof Error && /Corrupted download/.test(e.message)) {\n    // likely truncated stream — clear cache and retry once\n    await fs.remove(cacheFolder)\n    await cypress.install()\n  } else throw e\n}","preventionTips":["Ensure stable bandwidth for multi-hundred-MB downloads.","Free disk space before install.","Set CYPRESS_INSTALL_BINARY to a verified local file in air-gapped environments."],"tags":["install","download","size","network"],"backgroundTag":null,"analyzedSha":"0d85fdc91230885bca0a91df278312800a48b727","analyzedAt":"2026-08-12T16:24:28.056Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}