Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hangs indefinitely while running tests #1235

Closed
egucciar opened this issue Jan 29, 2018 · 46 comments
Closed

Hangs indefinitely while running tests #1235

egucciar opened this issue Jan 29, 2018 · 46 comments
Labels
Milestone

Comments

@egucciar
Copy link
Contributor

egucciar commented Jan 29, 2018

Current behavior:

While running my tests, Cypress suddenly stops responding. It will not continue running tests...

Desired behavior:

It shouldnt hang indefinitely with no way of me knowing why

How to reproduce:

not sure, i have a giant test suite with a loop. it was working fine until it wasnt.

Test code:

gigantum test suite

Additional Info (images, stack traces, etc)

  • Operating System: Win 10
  • Cypress Version: 1.4.1
  • Browser Version: 62
@egucciar
Copy link
Contributor Author

egucciar commented Feb 2, 2018

Just to note, i do not see anything SPECIFICALLY wrong with these test cases, but its certainly a few specific cases having this issue. Any ideas what may even cause indefinite hanging? Like hours long hanging on one test which runs fine in the runner?

@ksmahesh
Copy link

ksmahesh commented Feb 9, 2018

I do see behavior like this on jenkins run.
Enabling debug (DEBUG cypress:*) I see continuous output such as this

Fri, 09 Feb 2018 19:57:19 GMT cypress:server:timers child sending timer id 437 Fri, 09 Feb 2018 19:57:19 GMT cypress:server:timers child sending timer id 438 Fri, 09 Feb 2018 19:57:19 GMT cypress:server:timers child sending timer id 439 Fri, 09 Feb 2018 19:57:19 GMT cypress:server:timers child sending timer id 444 Fri, 09 Feb 2018 19:57:23 GMT cypress:server:timers child sending timer id 449 Fri, 09 Feb 2018 19:57:26 GMT cypress:server:timers clearing timer id 452 from queue { '452': { args: [], ms: 85000, cb: [Function] } } Fri, 09 Feb 2018 19:57:26 GMT cypress:server:timers queuing timer id 453 after 85000 ms Fri, 09 Feb 2018 19:57:26 GMT cypress:server:timers child received timer id 453 Fri, 09 Feb 2018 19:57:36 GMT cypress:server:timers child sending timer id 450 Fri, 09 Feb 2018 19:57:51 GMT cypress:server:timers clearing timer id 453 from queue { '453': { args: [], ms: 85000, cb: [Function] } } Fri, 09 Feb 2018 19:57:51 GMT cypress:server:timers queuing timer id 454 after 85000 ms Fri, 09 Feb 2018 19:57:51 GMT cypress:server:timers child received timer id 454

it continues to print out cypress:server:timers repeatedly without terminating.

Is there a way to terminate cypress process in such scenarios? Because I see this to happen repeatedly in my test suite.

@egucciar
Copy link
Contributor Author

This is kind of a huge deal breaker / blocker in terms of us using cypress. I wish there was more visibility on the issue.

@jennifer-shehane
Copy link
Member

@egucciar We really need a reproducible code example/repo to be able to begin work on this. There are an infinite number of variables that could be involved.

@jennifer-shehane jennifer-shehane added the stage: needs information Not enough info to reproduce the issue label Feb 12, 2018
@egucciar
Copy link
Contributor Author

@jennifer-shehane

considering the code / test suite is private intranet code (non public, id be breaking my NDA if i shared it) I can't actually make it public. Any suggestions on how to go about this? Capturing logs or anything ?

@kartikupreti
Copy link

I do see similar behavior of hanging without failing on Jenkins 2.0.105 run headless using the electron browser.

I do not have a large test suite either, the tests complete fine and the video gets saved but cypress doesn't quit after that and hangs just like that, on putting Debug to the command I see such messages over and over (just pasting a part of it)

cypress:server:timers child sending timer id 614
cypress:server:timers clearing timer id 617 from queue { '617': { args: [], ms: 85000, cb: [Function] } }
cypress:server:timers child received timer id 618

@ksmahesh
Copy link

@kartikupreti @egucciar dont you wish for a timeout functionality? Something that kills the cypress tests after say 10 mins?
I am using that hack right now in cypress/support/index.js where I use a setTimeout method to call window.close after pre-determined timeout.
Agreed, its a hack and it skips the remaining tests in spec file. But its definitely better than to have a continuously running process on Jenkins.
@jennifer-shehane I will try to provide with the script to reproduce this issue this weekend.

@michael-langley
Copy link

michael-langley commented Feb 17, 2018

FWIW I have seen this behavior a couple of times on the initial page load. A couple of times it killed the suite (which is fine) but other times it runs indefinitely. However I see it more so when a cy.request() returns a 500 ISE or a 504 error.

image

@kartikupreti
Copy link

@mlangley2010 I think The issue you are getting is different (and might just be specific to your application/gateway not responding/forwarding the response to the UI on time.. just increasing the pageLoadTimeout from cypress.json should help in your case)

@ksmahesh The kill functionality can be implemented probably just by putting a timeout around that stage/step in jenkins?
Im concerned as to why it happens or rather what is cypress expecting, since it happens inconsistently and I've not been able to reproduce it on my local system.

@kartikupreti
Copy link

kartikupreti commented Feb 17, 2018

Duplicate of #674

@brian-mann
Copy link
Member

@ksmahesh check out this issue. #1333 (comment)

You're seeing the timers continue to fire because the Browser is still open. So something is failing with closing the browser.

@michael-langley
Copy link

@kartikupreti It appears to not be happening anymore today. But no matter what I had the timeout set to Cypress would not advance past that failed step. My timeout was set to 60 seconds, and you can see the test had been running for 245.60, and that was the only step I had tried to run. Regardless, it sounds like the comment posted above in #1333 is a plausible explanation.

Thanks!

@brian-mann
Copy link
Member

@mlangley2010 If you're describing an error happening in a hook, then it could be related to #674 which is fixed in develop and being released tonight.

@egucciar
Copy link
Contributor Author

@brian-mann @jennifer-shehane

this seems to happen consistently whenever we create forEach loops to generate tests. Though tests run fine in the runner, upon running them inside Command Line, after getting through a few tests, it hangs indefinitely, no error message, nothing.

@egucciar
Copy link
Contributor Author

@ksmahesh how did u run the command line with DEBUG ? we are trying to find out why our suite is hanging

@shcallaway
Copy link

@egucciar Set the DEBUG environment variable: DEBUG=cypress:* cypress run

@egucciar
Copy link
Contributor Author

@shcallaway did you ever see your problem get resolved? Was it happening within a loop of some kind? We are seeing the same logs as you observed. Timer sending ID child receiving ID log. Same exact issue is happenign when we refactored some of our repetitive tests to leverage a .forEach.

We are trying to recreate the issue using Kitchen Sink suite.

@richdom81
Copy link

richdom81 commented Apr 19, 2018

I have a scenario that appears to be 100% reproducible. Its a very simple test that hangs at the very last step.

Running on Windows 10.

Using Cypress Binaries downloaded directly today 04-18-2018 - v1.8.2

Chrome Version 65

https://github.com/richdom81/CypressRepro

Let me know if more info is needed.

@jennifer-shehane
Copy link
Member

Yes, @richdom81 example can be reproduced with this code:

it('Guest Checkout', function () {
  cy.visit('https://www.prepsportswear.com/school/us/texas/el-paso/riverside-high-school-rangers/productlist?schoolid=190145&category=30')
  cy.get('#uxProductList > :nth-child(1) > :nth-child(4)').click()
})

The browser actually ends up freezing if you only visit the page and wait like 30 seconds also.

@richdom81
Copy link

Hi - Curious if anyone has a chance to take a look at this. We are planning to move our integration test strategy over to Cypress from Selenium, however if we are not able to access the school pages above (which is the bulk of our customer orders) we'll have to reconsider.

Any help would be greatly appreciated!.

@jennifer-shehane
Copy link
Member

@richdom81 I have brought the attention of the team to this bug, but as we are a small team, it may take some time to debug the root of the issue, as we are slated for other work at the moment.

We can prioritize bug fixes, do screensharing, and code reviews under our premium support - and could more quickly look into the issue with this kind of workflow. If you’re interested in this kind of premium support, please let us know by emailing support@cypress.io.

@nikolinas
Copy link

I'm experiencing the same issue running cy test in a Docker container on Jenkins. Are there any workarounds to fix the issue?

@bkrall

This comment has been minimized.

@richdom81
Copy link

For us, it had to do with how Cypress handels eventListeners. We had a is file that was attempting to clear all eventlisenters after cypress.runner.js cleared them.

The result was the Chrome Browser hanging from a forever loop due to our file.

@bahmutov
Copy link
Contributor

bahmutov commented May 18, 2018 via email

@kartikupreti
Copy link

To chime in
As I mentioned above we still see the same issue consistently while running cypress from the command line (with or without video recording / with or without docker )
./node_modules/.bin/cypress run -s ./cypress/tests/smoke/registration_test.js --reporter mocha-multi-reporters --reporter-options configFile=config.json
but as a workaround I add
cy.window().then(win => win.onbeforeunload = undefined); in the
beforeEach() hook for each test and all the tests ran and completed like a charm.
Really ❤️ cypress and the whole team behind it. 🥇

@egucciar
Copy link
Contributor Author

egucciar commented May 18, 2018

Oh my. Could it be the onbeforeunload handler in some apps? I don't work at the company anymore where we had the hanging tests but come to think of it, in a suite of near 100 tests, there was only a dozen that would consistently hang. I implemented the features it was testing and for that feature set, And only that feature set , I setup an onbeforeunload handler. It's the only feature in the app that sets up such a handler and the only tests that were hanging interact with that feature . It would be really interesting if that's been the root cause

@piozaj

This comment has been minimized.

@nickspiel
Copy link

nickspiel commented May 26, 2018

In my case I was migrating tests from nightmare where you need to fire the callback when the test is complete. I had left the callback in the function call.

Was:
it('should test something', (done) => { ... })

Now:
it('should test something', () => { ... })

Tests no longer hang - this wont be a fix for the majority but thought I would add it for others to check.

@nickspiel
Copy link

nickspiel commented May 29, 2018

Also, for those using docker adding ipc: host to docker-compose.yml helped with some weird issues when running in CI. #350

@kartikupreti
Copy link

@egucciar It might be, or you might have a modal or dialog open that prevents the browser from closing.

I was able to see that cypress (looked like it) was hung after the test was done because our webpage threw a popup ( to save or discard changes) which doesnt let the user just close the tab with unsaved changes, I ran cypress with --headed and I could see the the browser just remained open indefintely after the failing test due to this. So it used to look like its hanging in video recording step but in reality the browser(electron) itself hadn't closed.

and I added appropriate beforeEach and afterEach hooks and now it all runs good always.

@ksmahesh this might be the case for you too, your debug log is similar to how mine was.

@egucciar
Copy link
Contributor Author

egucciar commented Jun 2, 2018

Yep. As I recall the onbeforeunload created a dialog so the user would not lose their unsaved changes.

@jennifer-shehane jennifer-shehane added stage: needs investigating Someone from Cypress needs to look at this and removed stage: needs information Not enough info to reproduce the issue labels Jun 4, 2018
@OmriAharon
Copy link

OmriAharon commented Jun 5, 2018

Happened for me as well - after a specific test it would just fail to close, logs indicating it's just sending timers, not sure what that means. Test didn't do anything, just had a simple selector and assertion. After adding --browser chrome to the cypress run command it was resolved, so might be something with Electron. Might also be related to #1333.

Happened both on versions 2.1.0 and 3.0.1.

@nikolinas
Copy link

nikolinas commented Aug 4, 2018

Switching to Chrome instead of using Electron as default browser fixed the issue for me as well!!! Yay!

I was usingcypress/base:8 Docker image and ended up switching to cypress/browsers:chrome67 to install all of the dependencies + browsers on Jenkins and then running the following command to execute the tests:

cypress run --browser chrome

I'm also using cypress version 3.0.3.

@astehlik
Copy link

astehlik commented Aug 9, 2018

For me the problem currently occurs with version 3.0.3 and Electron in a Docker container.

Working workaround are:

  • Downgrading to 2.1.0
  • Using Google Chrome as browser

@astehlik
Copy link

astehlik commented Aug 9, 2018

I just found out one more possible error source.

We are using the beforeunload callback in our application.

Chrome seems to bypass it with an error message in the console:

[Intervention] Blocked attempt to show a 'beforeunload' confirmation panel for a frame that never had a user gesture since its load. https://www.chromestatus.com/feature/5082396709879808

Electron just stops at some point and becomes totally unresponsive.

Simple workaround ist to check the User agent for Cypress:

if (!navigator.userAgent.includes('Cypress')) {
    window.addEventListener("beforeunload", this.beforeunloadFunction)
}

@egucciar
Copy link
Contributor Author

egucciar commented Aug 9, 2018

@astehlik that was one of the known causes I believe but was existing even in 2.x. If you scroll up in this thread you will see too.

@georgesequeira
Copy link

georgesequeira commented Aug 23, 2018

Environment: CircleCI-2.1 (docker image: cypress/base:8)
Browser: Electron (switching to Chrome didn't help)
Version: 3.1.0

We have had a hard time reproducing this issue because it would fail on various tests (thankfully it was the same few). As we continue to debug this (i've already sank 4 days into this, i have updated how we run our cypress tests to kill hanging tests and re-run. I discuss how here:

#1333 (comment)

@brian-mann
Copy link
Member

We fixed the hanging issues when running in CI with Electron where it would start a spec but never open the browser or move on.

@georgesequeira Is there something different in here than what we're aware of?

@brian-mann brian-mann added this to the 3.1.0 milestone Aug 23, 2018
@brian-mann
Copy link
Member

I'm going to close this issue as I believe it's been resolved by the primary cause of the specs hanging in 3.1.0. If there are separate issues those should be opened as new issues.

@sjones6
Copy link

sjones6 commented Aug 23, 2018

Thanks @brian-mann. I’ll do the update next week and see if it’s resolved.

@georgesequeira
Copy link

@brian-mann filed: #2392

@jennifer-shehane jennifer-shehane removed the stage: needs investigating Someone from Cypress needs to look at this label Aug 28, 2018
@rlucha
Copy link

rlucha commented Sep 17, 2018

@astehlik solution fixed our problem, too.

@dkelkhoff
Copy link

dkelkhoff commented Sep 20, 2018 via email

@vitalii
Copy link

vitalii commented Nov 2, 2018

still actual for me. Tried to all the workarounds posted here. Didn't help

@jennifer-shehane
Copy link
Member

Since this issue is covering quite a broad spectrum of performance issues at this point - we will lock this issue for discussion.

Please reopen any issues you are experience (or comment on existing issues - check our performance tag) with reproducible examples. We cannot do anything without the exact code to run to reproduce and any issues opened without reproducible code will be closed.

@cypress-io cypress-io locked as resolved and limited conversation to collaborators Apr 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests