Skip to content

Commit

Permalink
fix: Hanging indefinitely when unzip fails with an empty error (#28850)
Browse files Browse the repository at this point in the history
  • Loading branch information
CamilleDrapier committed Feb 14, 2024
1 parent ea99fa4 commit 7c4d941
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 4 deletions.
4 changes: 4 additions & 0 deletions cli/CHANGELOG.md
Expand Up @@ -12,6 +12,10 @@ _Released 2/13/2024 (PENDING)_

- Improved accessibility of the Cypress App in some areas. Addressed in [#28774](https://github.com/cypress-io/cypress/pull/28774).

**Bugfixes:**

- Fixed an issue with the unzip promise never being rejected when an empty error happens. Fixed in [#28850](https://github.com/cypress-io/cypress/pull/28850).

## 13.6.4

_Released 1/30/2024_
Expand Down
8 changes: 4 additions & 4 deletions cli/lib/tasks/unzip.js
Expand Up @@ -84,11 +84,11 @@ const unzip = ({ zipFilePath, installDir, progress }) => {
return resolve()
})
.catch((err) => {
if (err) {
debug('error %s', err.message)
const error = err || new Error('Unknown error with Node extract tool')

return reject(err)
}
debug('error %s', error.message)

return reject(error)
})
}

Expand Down
39 changes: 39 additions & 0 deletions cli/test/lib/tasks/unzip_spec.js
Expand Up @@ -132,6 +132,45 @@ describe('lib/tasks/unzip', function () {
})
})

it('can try unzip first then fall back to node unzip and fails with an empty error', async function () {
const zipFilePath = path.join('test', 'fixture', 'example.zip')

sinon.stub(unzip.utils.unzipTools, 'extract').callsFake(() => {
return new Promise((_, reject) => reject())
})

const unzipChildProcess = new events.EventEmitter()

unzipChildProcess.stdout = {
on () {},
}

unzipChildProcess.stderr = {
on () {},
}

sinon.stub(cp, 'spawn').withArgs('unzip').returns(unzipChildProcess)

setTimeout(() => {
debug('emitting unzip error')
unzipChildProcess.emit('error', new Error('unzip fails badly'))
}, 100)

try {
await unzip
.start({
zipFilePath,
installDir,
})
} catch (err) {
logger.error(err)
expect(err.message).to.include('Unknown error with Node extract tool')

return
}
throw new Error('should have failed')
})

it('calls node unzip just once', function (done) {
const zipFilePath = path.join('test', 'fixture', 'example.zip')

Expand Down

4 comments on commit 7c4d941

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 7c4d941 Feb 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.6.5/linux-x64/develop-7c4d941d462282118fce124af7d4100c0c04a8fe/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 7c4d941 Feb 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.6.5/darwin-arm64/develop-7c4d941d462282118fce124af7d4100c0c04a8fe/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 7c4d941 Feb 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.6.5/darwin-x64/develop-7c4d941d462282118fce124af7d4100c0c04a8fe/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 7c4d941 Feb 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.6.5/win32-x64/develop-7c4d941d462282118fce124af7d4100c0c04a8fe/cypress.tgz

Please sign in to comment.