cypress-io/cypress · error · Error

Corrupted download Expected downloaded file to have size: $

Error message

Corrupted download

Expected downloaded file to have size: ${expectedSize}
Computed size: ${filesize}

What it means

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.

Source

Thrown at cli/lib/tasks/download.ts:191

    debug('only checking expected file size %d', expectedSize)

    const filesize: number = await util.getFileSize(filename)

    if (filesize === expectedSize) {
      debug('downloaded file has the expected size ✅')

      return
    }

    debug('raising error: file size mismatch')
    const text = stripIndent`
        Corrupted download

        Expected downloaded file to have size: ${expectedSize}
        Computed size: ${filesize}
      `

    throw new Error(text)
  }

  debug('downloaded file lacks checksum or size to verify')

  return
}

// downloads from given url
// return an object with
// {filename: ..., downloaded: true}
const downloadFromUrl = ({ url, downloadDestination, progress, ca, version, redirectTTL = defaultMaxRedirects }: any): any => {
  if (redirectTTL <= 0) {
    return Promise.reject(new Error(
      stripIndent`
          Failed downloading the Cypress binary.
          There were too many redirects. The default allowance is ${defaultMaxRedirects}.
          Maybe you got stuck in a redirect loop?
        `,

View on GitHub (pinned to 0d85fdc912)

Solutions

  1. Free disk space and re-run `cypress install` after removing ~/.cache/Cypress.
  2. Bypass a misbehaving proxy/CDN by setting CYPRESS_INSTALL_BINARY to a trusted URL or local file.
  3. If using a mirror, ensure it preserves content-length and serves the complete artifact; fall back to the default download source.
  4. Verify network stability for large file transfers (the Cypress binary is hundreds of MB).

Example fix

# before: size mismatch on install
# after:
CYPRESS_INSTALL_BINARY=/path/to/verified/cypress.zip cypress install
Defensive patterns

Strategy: retry

Try / catch

try {
  await cypress.install()
} catch (e) {
  if (e instanceof Error && /Corrupted download/.test(e.message)) {
    // likely truncated stream — clear cache and retry once
    await fs.remove(cacheFolder)
    await cypress.install()
  } else throw e
}

Prevention

When it happens

Trigger: `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.

Common situations: 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.

Related errors


AI-assisted analysis of cypress-io/cypress@0d85fdc912 (2026-08-12). Data as JSON: /api/errors/bb8b22e538a39b42. Report an issue: GitHub.