Skip to content

Commit 6e90546

Browse files
author
Camille Drapier
committed
fix: Hanging indefinitely when unzip fails with an empty error
1 parent 4af2a29 commit 6e90546

File tree

3 files changed

+51
-4
lines changed

3 files changed

+51
-4
lines changed

cli/CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
<!-- See the ../guides/writing-the-cypress-changelog.md for details on writing the changelog. -->
2+
## 13.6.5
3+
4+
_Released 2/15/2024 (PENDING)_
5+
6+
**Bugfixes:**
7+
8+
- 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).
9+
210
## 13.6.4
311

412
_Released 1/30/2024_

cli/lib/tasks/unzip.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ const unzip = ({ zipFilePath, installDir, progress }) => {
8484
return resolve()
8585
})
8686
.catch((err) => {
87-
if (err) {
88-
debug('error %s', err.message)
87+
const error = err || new Error('Unknown error with Node extract tool')
8988

90-
return reject(err)
91-
}
89+
debug('error %s', error.message)
90+
91+
return reject(error)
9292
})
9393
}
9494

cli/test/lib/tasks/unzip_spec.js

+39
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,45 @@ describe('lib/tasks/unzip', function () {
132132
})
133133
})
134134

135+
it('can try unzip first then fall back to node unzip and fails with an empty error', async function () {
136+
const zipFilePath = path.join('test', 'fixture', 'example.zip')
137+
138+
sinon.stub(unzip.utils.unzipTools, 'extract').callsFake(() => {
139+
return new Promise((_, reject) => reject())
140+
})
141+
142+
const unzipChildProcess = new events.EventEmitter()
143+
144+
unzipChildProcess.stdout = {
145+
on () {},
146+
}
147+
148+
unzipChildProcess.stderr = {
149+
on () {},
150+
}
151+
152+
sinon.stub(cp, 'spawn').withArgs('unzip').returns(unzipChildProcess)
153+
154+
setTimeout(() => {
155+
debug('emitting unzip error')
156+
unzipChildProcess.emit('error', new Error('unzip fails badly'))
157+
}, 100)
158+
159+
try {
160+
await unzip
161+
.start({
162+
zipFilePath,
163+
installDir,
164+
})
165+
} catch (err) {
166+
logger.error(err)
167+
expect(err.message).to.include('Unknown error with Node extract tool')
168+
169+
return
170+
}
171+
throw new Error('should have failed')
172+
})
173+
135174
it('calls node unzip just once', function (done) {
136175
const zipFilePath = path.join('test', 'fixture', 'example.zip')
137176

0 commit comments

Comments
 (0)