headless runner does not exit
See original GitHub issueCurrent behavior:
When I run a test spec it does not exit once finished. I originally thought this was due to using cy.exec
, but the bug occurs with this simple test spec.
However, turning off video recording stops reproducing the bug. I have another test that runs a script which leaves a detached process running (logging database output). That reproduces the bug even with video=false
. Unfortunately I cant post that.
Expected behavior:
The headless runner should exit with 0 for success and >0 for failure.
How to reproduce the current behavior:
Run the test code on a machine without ffmpeg.
Test code:
describe('cypress bug', () => {
it('will not exit the headless runner', () => {
expect(true).to.equal(false);
})
})
Additional Info (images, notes, stack traces, etc)
Gitter thread: https://gitter.im/cypress-io/cypress?at=5909d020edf919574a71eec1
wtfnode
Started video recording: /home/daniel/src/edrolo/tod_project/tod_django/react/cypress/videos/jywf7.mp4
(Tests Starting)
cypress bug
✓ will not exit the headless runner
1 passing (99ms)
(Tests Finished)
- Tests: 1
- Passes: 1
- Failures: 0
- Pending: 0
- Duration: 0 seconds
- Screenshots: 0
- Video Recorded: true
- Cypress Version: 0.19.2
Warning: We failed to record the video.
This error will not alter the exit code.
Error: ffmpeg exited with code 1: Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
at ChildProcess.<anonymous> (/home/daniel/.cypress/Cypress/resources/app/node_modules/fluent-ffmpeg/lib/processor.js:177:22)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
[WTF Node?] open handles:
- File descriptors: (note: stdio always exists)
- fd 2 (tty) (stdio)
- fd 0 (tty)
- Child processes
- PID 2540
- Entry point: /home/daniel/.nvm/versions/node/v6.10.2/lib/node_modules/cypress-cli/lib/utils.coffee:210
I’m using the following script as a workaround for our CI system. It reads stdout of the cypress runner, parses the failure number and exits appropriately.
/*
* Workaround for a bug in Cypress where a file descriptor is
* left open, and node will not exit.
* Runs Cypress, reads stdout of the tests, and exits manually
* with the number of failed tests as the exit code
* https://gitter.im/cypress-io/cypress?at=59082b056aea30763d6062b8
*/
const spawn = require('child_process').spawn;
let failureCount = null;
const proc = spawn('cypress', ['run'].concat(process.argv.slice(2)), {
cwd: `${__dirname}/..`,
});
proc.stdout.on('data', (data) => {
data.toString().split('\n').forEach((line) => {
console.log(line);
if (line.indexOf('- Failures:') > -1) {
failureCount = Number(line.split(':')[1]);
}
if (line.indexOf('(All Done)') > -1) {
if (typeof failureCount !== 'number') {
throw new Error('failureCount has not been read by the script.');
}
process.exit(failureCount);
}
});
});
- Operating System: Linux (Ubuntu Gnome 17.04)
- Cypress Version: Cypress CLI: 0.13.1
Issue Analytics
- State:
- Created 6 years ago
- Reactions:14
- Comments:14 (4 by maintainers)
Top GitHub Comments
Woah, 3 years and still not fixed?
I’m having the same problem. Running it headless on my mac os machine it exits with code 0 but when running it on windows machine on TeamCity it never exits after completing the tests.
Edit: Just tested it in another windows machine and the same thing happens.
Edit2: This just happens when using the mocha teamcity reporter:
cypress run --reporter @cypress/mocha-teamcity-reporter
I’ll open an issue for that