cypress: Cypress Hangs Running Tests With Electron (Headless or Headed)

Current behavior:

Our CI/CI pipeline runs our Cypress tests on a schedule. This has been working as expected. However, yesterday (12 September 2019), the behavior changed. Instead of running to completion (with or without errors), the test suite now hangs on one particular test case. The CI/CD pipeline eventually times out after 60 minutes.

Running the tests manually on my machine with Chrome via npx cypress run --browser chrome or npx cypress open --browser chrome works just fine.

Running the tests manually with Electron, headless or headless, does not. It exhibits the same hang that our CI/CD pipeline exhibits.

Digging into it I see that it is hanging on the afterEach() action, trying to revisit the same page, via cy.visit() on which the test started. Playing around with things, It seems to fail the same way, any time cy.visit() is called twice in the context of the same test of describe() block.

Even odder, turning on debug logging via

env DEBUG=cypress:* npx cypress run --browser electron 2>&1 | tee cypress-log.txt

completed successfully.

Desired behavior:

Tests should run to completion and not hang.

Steps to reproduce: (app code and test code)

  1. Clone this repo: https://github.com/nbcarey/cypress-io-hangs-with-electron
  2. Running the command npm run succeeds-with-chrome gives you the happy path.
  3. Running the command npm run hangs-with-electron gives you the unhappy path.

Versions

  • MacOS Mojave, v10.14.6

  • Chrome, v77.0.3865.75

  • Node.js, v10.16.3

  • Npm, v6.11.3

  • Cypress, v3.4.1 (and Electron 61?)

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 5
  • Comments: 26 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Hey @julian-sf, Electron 5.0.10 upgrade (Chrome 73 - PR: #4720) is releasing with 3.5.0, which should come out later this week. So hopefully you won’t need to wait much longer.

We’re also working on upgrading to Electron 6 and keeping it up to date so this big gap doesn’t happen again.

Yeah, so our team’s been running into this issue as well. A LOT of the problems I’ve seen relating to this are just coming from old Electron bugs. Electron 61 was released TWO entire years ago on September 5, 2017. So yeah, this is going to be an issue until we can get a newer version of Electron running with Cypress.

In a way this IS a Cypress issue, because we need to be able to run on a more recent version of electron. The Cypress team is currently working on an upgrade, so it looks like we probably just have to wait until then.

It hangs in our CI environment as well (headless Electron on Windows) since upgrading from 3.4.1 to ~3.7~ 3.5.0.

Edit: trying to see if it works in 3.7.0 right now…

Edit 2: still hangs in v 3.7.0.

@fr0 Indeed, we have had some hiccups. But… soon. We aren’t adding any new features for 3.5.0, just making sure that what we’re releasing is quality.

@flotwig Awesome! I know you guys have been working hard on it. I appreciate the update and I’m very much looking forward to the new version!

This issue was resolved for me in 3.5.0. 🎉

Didn’t manage to create a test repo yet, but here’s the debug output of the test run of the small test-case from https://github.com/cypress-io/cypress/issues/5139#issuecomment-533632670: https://gist.github.com/rudolfs/25bc14986d4d1451d98cee3c4307fb30

It seems to hang on trying to clean up a request from the first test, which has a timeout: null.

Headless electron has started hanging only on our CI build with both 3.5.0 and 3.6.0, while it worked in 3.4.1. It hangs after finishing the first spec file and before starting the second spec file.

I do have multiple cy.visit() calls in my spec.

In addition, there is also #5558 and #5603 that seem very similar. Maybe they are more applicable to the 3.5.0 and 3.6.0 versions?

We were finally able to figure out our issue today related to electron not working. It was related to our webpack upgrade and failing on a form try catch error block not cooperating with electron. IMO an electron bug

I’m also seeing this issue with Electron 61 in any tests where I need to switch users for a multi-user interaction.