Skip to content

Commit

Permalink
fix: Hanging indefinitely when unzip fails with an empty error
Browse files Browse the repository at this point in the history
  • Loading branch information
CamilleDrapier authored and Camille Drapier committed Feb 5, 2024
1 parent 835d493 commit 2ad495d
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 5 deletions.
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

0 comments on commit 2ad495d

Please sign in to comment.