Skip to content

Commit

Permalink
Make informative error message
Browse files Browse the repository at this point in the history
  • Loading branch information
davidiamaf committed Jan 4, 2022
1 parent bf172dd commit ff5ed56
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions cli/lib/tasks/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const fs = require('../fs')
const util = require('../util')

const defaultBaseUrl = 'https://download.cypress.io/'
const defaultMaxRedirects = 10

const getProxyForUrlWithNpmConfig = (url) => {
return getProxyForUrl(url) ||
Expand Down Expand Up @@ -186,9 +187,15 @@ const verifyDownloadedFile = (filename, expectedSize, expectedChecksum) => {
// downloads from given url
// return an object with
// {filename: ..., downloaded: true}
const downloadFromUrl = ({ url, downloadDestination, progress, ca, version, redirectTTL = 10 }) => {
const downloadFromUrl = ({ url, downloadDestination, progress, ca, version, redirectTTL = defaultMaxRedirects }) => {
if (redirectTTL <= 0) {
return Promise.reject(new Error('Excessive redirects!'))
return Promise.reject(new Error(
stripIndent`
Failed downloading the Cypress binary.
There were too many redirects. The default allowance is ${defaultMaxRedirects}.
If you need more, use environment variable CYPRESS_DOWNLOAD_REDIRECT_TTL
`,
))
}

return new Promise((resolve, reject) => {
Expand Down

0 comments on commit ff5ed56

Please sign in to comment.