Misleading Cypress "expected file size 82" in download debug logs
Current behavior
Debug logs show
cypress:cli expected file size 82
when installing the Cypress binary with cypress install.
The file size of the Cypress binary is however 193682427 (Cypress 13.14.2) according to
Content-LengthX-Amz-Meta-Size
Desired behavior
The debug logs should show the file size of the Cypress binary, not the Content-Length of the HTTP 302 redirect from
https://download.cypress.io/desktop/...
to
https://cdn.cypress.io/desktop/<version>/<platform>-<arch>/cypress.zip
Test code to reproduce
cd $(mktemp -d)
npm init -y
CYPRESS_INSTALL_BINARY=0 npm install cypress@latest --save-dev
DEBUG=cypress:cli npx cypress install --force
Cypress Version
First reported on Cypress version: 13.14.2
Continues to be reproducible on version. 14.1.0
Node version
v20.17.0 and v22.14.0 LTS
Operating System
Ubuntu 22.04.5 LTS and
Ubuntu 24.04.2 LTS and
Windows 11
Debug Logs
$ CYPRESS_INSTALL_BINARY=0 npm install cypress --save-dev
DEBUG=cypress:cli npx cypress install --force
added 173 packages in 21s
39 packages are looking for funding
run `npm fund` for details
cypress:cli NODE_OPTIONS is not set +0ms
cypress:cli parsed cli options { force: true } +112ms
cypress:cli installing with options {"force":true} +0ms
cypress:cli detecting arch { osPlatform: 'linux', osArch: 'x64' } +1ms
cypress:cli arm uname -m result: { stdout: 'x86_64' } +20ms
cypress:cli version in package.json is 13.14.2, version to install is 13.14.2 +20ms
cypress:cli Reading binary package.json from: /home/mike/.cache/Cypress/13.14.2/Cypress/resources/app/package.json +0ms
Cypress 13.14.2 is installed in /home/mike/.cache/Cypress/13.14.2
cypress:cli performing force install over existing binary +77ms
cypress:cli checking local file /home/mike/github/13.14.2 cwd /home/mike/github/tmp/test +0ms
cypress:cli Cypress already installed at /home/mike/.cache/Cypress/13.14.2 +0ms
cypress:cli but the installation was forced +0ms
cypress:cli preparing to download and unzip version 13.14.2 to path /home/mike/.cache/Cypress/13.14.2 +0ms
Installing Cypress (version: 13.14.2)
cypress:cli needed Cypress version: 13.14.2 +0ms
cypress:cli source url https://download.cypress.io/desktop/13.14.2?platform=linux&arch=x64 +0ms
cypress:cli downloading cypress.zip to "/tmp/cypress-6316.zip" +0ms
cypress:cli Downloading package {
url: 'https://download.cypress.io/desktop/13.14.2?platform=linux&arch=x64',
proxy: null,
downloadDestination: '/tmp/cypress-6316.zip'
} +1ms
cypress:cli expected file size 82 +470ms
cypress:cli redirect version: 13.14.2 +0ms
cypress:cli redirect url: https://cdn.cypress.io/desktop/13.14.2/linux-x64/cypress.zip +0ms
cypress:cli Downloading package {
url: 'https://cdn.cypress.io/desktop/13.14.2/linux-x64/cypress.zip',
proxy: null,
downloadDestination: '/tmp/cypress-6316.zip'
} +0ms
cypress:cli expected checksum c8379c3f09314e65117297938571f3dc357fb3a6d7797264b39e9905b5c357b3d37d3aae2acbbc8cc0a4f910c7b0d87e2de835b388d94713ddd9060c5b9fc56d +130ms
⠼ Downloading Cypress 100% 0s
cypress:cli downloading finished +36s
⠋ Downloading Cypress 100% 0s
cypress:cli downloaded file has the expected checksum and size ✅ +586ms
cypress:cli verified +0ms
✔ Downloaded Cypress
✔ Unzipped Cypress
✔ Downloaded Cypress
✔ Unzipped Cypress
✔ Finished Installation /home/mike/.cache/Cypress/13.14.2
You can now open Cypress by running one of the following, depending on your package manager:
- npx cypress open
- yarn cypress open
- pnpm cypress open
https://on.cypress.io/opening-the-app
Other
Workaround to see expected file size:
export CI=1
Well, this was the originally coded behavior. I can't completely grasp while looking at this briefly why we would have a OR value of response.headers['content-length']) here: https://github.com/cypress-io/cypress/blob/snyk-fix-7b3f6ffb824a82ccc3d6393cc519881c/cli/lib/tasks/download.js#L242
It's not failing verification though which makes me thing these values must be the same?
@jennifer-shehane
The verification is working correctly. It's only the one line of debug output which is wrong:
cypress:cli expected file size 82
As you say, it's the original behavior. The bug has been there unnoticed all the time going back to Cypress 10.
So, there are actually two issues:
- Output of
cypress:cli expected file size 82where this is not a file size, just a content-length of a redirect response - When
cypress installis run locally (not in CI), the real data about file size e.g.expected file size 193682427is overwritten by theDownloading Cypress 100%outputs, which refreshes as the download progresses.
Here are the debug logs running in CI (export CI=1), where the file size is shown correctly cypress:cli expected file size 193682427 in addition to the previous line cypress:cli expected file size 82 related to the redirect:
$ CI=1 DEBUG=cypress:cli npx cypress install --force
cypress:cli NODE_OPTIONS is not set +0ms
cypress:cli parsed cli options { force: true } +137ms
cypress:cli installing with options {"force":true} +0ms
cypress:cli detecting arch { osPlatform: 'linux', osArch: 'x64' } +2ms
cypress:cli arm uname -m result: { stdout: 'x86_64' } +15ms
cypress:cli version in package.json is 13.14.2, version to install is 13.14.2 +16ms
cypress:cli Reading binary package.json from: /home/mike/.cache/Cypress/13.14.2/Cypress/resources/app/package.json +0ms
cypress:cli no binary installed under cli version +43ms
cypress:cli checking local file /home/mike/github/13.14.2 cwd /home/mike/github/tmp/test +1ms
cypress:cli Cypress already installed at /home/mike/.cache/Cypress/13.14.2 +0ms
cypress:cli but the installation was forced +0ms
cypress:cli preparing to download and unzip version 13.14.2 to path /home/mike/.cache/Cypress/13.14.2 +0ms
Installing Cypress (version: 13.14.2)
cypress:cli needed Cypress version: 13.14.2 +0ms
cypress:cli source url https://download.cypress.io/desktop/13.14.2?platform=linux&arch=x64 +0ms
cypress:cli downloading cypress.zip to "/tmp/cypress-6391.zip" +0ms
cypress:cli Downloading package {
url: 'https://download.cypress.io/desktop/13.14.2?platform=linux&arch=x64',
proxy: null,
downloadDestination: '/tmp/cypress-6391.zip'
} +1ms
cypress:cli expected file size 82 +275ms
cypress:cli redirect version: 13.14.2 +0ms
cypress:cli redirect url: https://cdn.cypress.io/desktop/13.14.2/linux-x64/cypress.zip +0ms
cypress:cli Downloading package {
url: 'https://cdn.cypress.io/desktop/13.14.2/linux-x64/cypress.zip',
proxy: null,
downloadDestination: '/tmp/cypress-6391.zip'
} +1ms
cypress:cli expected checksum c8379c3f09314e65117297938571f3dc357fb3a6d7797264b39e9905b5c357b3d37d3aae2acbbc8cc0a4f910c7b0d87e2de835b388d94713ddd9060c5b9fc56d +116ms
cypress:cli expected file size 193682427 +0ms
cypress:cli downloading finished +37s
cypress:cli verifying checksum and file size +0ms
cypress:cli downloaded file has the expected checksum and size ✅ +524ms
cypress:cli verified +4ms
cypress:cli finished downloading file: /tmp/cypress-6391.zip +38s
cypress:cli removing zip file /tmp/cypress-6391.zip +8s
You can now open Cypress by running one of the following, depending on your package manager:
- npx cypress open
- yarn cypress open
- pnpm cypress open
https://on.cypress.io/opening-the-app