question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

headless runner does not exit

See original GitHub issue

Current 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:closed
  • Created 6 years ago
  • Reactions:14
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Surm4commented, Sep 3, 2020

Woah, 3 years and still not fixed?

1reaction
bruno-gouveiacommented, Mar 27, 2019

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Headless macro does not exit after finishing - Usage & Issues
I am setting up to run some batch processing on a linux cluster using headless mode. I can successfully run a test script,...
Read more >
Jest-Puppeteer Why warning "Jest did not exit one second ...
Jest did not exit one second after the test run has completed. This usually means that there are asynchronous operations that weren't ......
Read more >
Command Line - cypress - w3resource
The –no-exit option is used to keep the Cypress Test Runner open after the tests in a spec file run. --parallel, This is...
Read more >
cy.pause() now pauses test while running cypress run --headed
cy.pause() will not be ignored and pause a test when --headed and --no-exit flags are passed to cypress run.
Read more >
Introduction | Cypress Documentation
Running headless tests without Xvfb. Using the ELECTRON_RUN_AS_NODE=1 env var is experimental and not fully tested, so may not work in all environments....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found