Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Hanging indefinitely when unzip fails with an empty error #28850

Merged
merged 1 commit into from Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion cli/CHANGELOG.md
@@ -1,12 +1,16 @@
<!-- See the ../guides/writing-the-cypress-changelog.md for details on writing the changelog. -->
## 13.6.5
## 13.6.5

_Released 2/13/2024 (PENDING)_

**Misc:**

- 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