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

Cypress takes forever to complete / hangs during tests #9350

Closed
simplenotezy opened this issue Nov 26, 2020 · 28 comments
Closed

Cypress takes forever to complete / hangs during tests #9350

simplenotezy opened this issue Nov 26, 2020 · 28 comments

Comments

@simplenotezy
Copy link

simplenotezy commented Nov 26, 2020

Current behavior

When running my tests on my CI (Jenkins) tests takes more than an hour to complete (possibly never completing)

They run fine on my macOS. I have just updated from version 5 to 6 to test if that could solve anything, but the same error happens.

When I go in and inspect the Console Output from the current job (that runs my deployment and cypress tests), it is just stuck here:

image

The whole output is this:

+ yarn cypress run --browser chrome
yarn run v1.22.4
$ /var/lib/jenkins/workspace/my-project-production/node_modules/.bin/cypress run --browser chrome
Warning: We failed to trash the existing run results.

This error will not alter the exit code.

Error: EACCES: permission denied, unlink '/var/lib/jenkins/workspace/my-project-production/cypress/screenshots/product.js/Basic product tests -- Can add quantity -- before all hook (failed).png'

================================================================================

	(Run Starting)

tput: No value for $TERM and no -T specified
	┌────────────────────────────────────────────────────────────────────────────────────────────────┐
	│ Cypress:    5.2.0                                                                              │
	│ Browser:    Chrome 86                                                                          │
	│ Specs:      4 found (general.js, product.js, productlist.js, search.js)                        │
	└────────────────────────────────────────────────────────────────────────────────────────────────┘


────────────────────────────────────────────────────────────────────────────────────────────────────
																																																		
	Running:  general.js                                                                      (1 of 4)


	Basic website navigation
		✓ It contains CVR number (4099ms)
		✓ Can go to product (4539ms)
		✓ Can go back to homepage by clicking logo (442ms)
		✓ Can change language (2434ms)
		✓ Can change currency (7205ms)
		✓ Cannot sign up with invalid e-mail for newsletter (2603ms)


	6 passing (22s)


	(Results)

	┌────────────────────────────────────────────────────────────────────────────────────────────────┐
	│ Tests:        6                                                                                │
	│ Passing:      6                                                                                │
	│ Failing:      0                                                                                │
	│ Pending:      0                                                                                │
	│ Skipped:      0                                                                                │
	│ Screenshots:  0                                                                                │
	│ Video:        true                                                                             │
	│ Duration:     21 seconds                                                                       │
	│ Spec Ran:     general.js                                                                       │
	└────────────────────────────────────────────────────────────────────────────────────────────────┘


	(Video)

	-  Started processing:  Compressing to 32 CRF                                                     
	-  Finished processing: /var/lib/jenkins/workspace/my-project-production/cypress/vide    (4 seconds)
													os/general.js.mp4                                                         


────────────────────────────────────────────────────────────────────────────────────────────────────
																																																		
	Running:  product.js                                                                      (2 of 4)


	Basic product tests
		✓ Can add quantity (2681ms)
		✓ Can view product details (675ms)
		✓ Can add color (338ms)
		✓ Requires size to be chosen (714ms)
		✓ Can add size (1112ms)
		✓ Can add to cart and cart opens (314ms)
		✓ Can remove item from cart (354ms)
		✓ Can close cart (158ms)

	Can purchase
		✓ Can go to checkout (1055ms)
		✓ Fails on empty e-mail (807ms)
		✓ Validates e-mail (667ms)
		✓ Can fill out the form (1046ms)
		✓ Remembers form on page reload (1359ms)
		✓ Can enter seperate billing address (541ms)
		✓ Rejects invalid coupon code (3422ms)
		✓ Cannot proceed without entering e-mail (1353ms)
		✓ Can proceed to delivery (249ms)
		✓ Cannot proceed without choosing delivery method (231ms)
		✓ Can proceed to payment (210ms)


	19 passing (18s)


	(Results)

	┌────────────────────────────────────────────────────────────────────────────────────────────────┐
	│ Tests:        19                                                                               │
	│ Passing:      19                                                                               │
	│ Failing:      0                                                                                │
	│ Pending:      0                                                                                │
	│ Skipped:      0                                                                                │
	│ Screenshots:  0                                                                                │
	│ Video:        true                                                                             │
	│ Duration:     17 seconds                                                                       │
	│ Spec Ran:     product.js                                                                       │
	└────────────────────────────────────────────────────────────────────────────────────────────────┘


	(Video)

	-  Started processing:  Compressing to 32 CRF                                                     
	-  Finished processing: /var/lib/jenkins/workspace/my-project-production/cypress/vide    (3 seconds)
													os/product.js.mp4                                                         


────────────────────────────────────────────────────────────────────────────────────────────────────
																																																		
	Running:  productlist.js                                                                  (3 of 4)


	Sidebar
		✓ Can open filters (4901ms)
		✓ Can close filters (771ms)
		✓ Can close filters clicking outside element (734ms)

	Sort by
		✓ Can open dropdown (1073ms)
		✓ Closes when clicking outside (334ms)
		✓ Can change sorting (low-to-high) (4935ms)

	Filtering
		✓ Can see products in specific category (2366ms)
		✓ Removes filter when clicking clear filters (681ms)

	List
		✓ Loads more products when clicking load more (6159ms)
		✓ Loads more products when scrolling down (4515ms)
		✓ It ensures product is in view when going back (7122ms)
		✓ It shows a button to go to previous page when landing on page 2 (255ms)
		✓ It can go to previous page when clicking load previous button (4095ms)


	13 passing (39s)


	(Results)

	┌────────────────────────────────────────────────────────────────────────────────────────────────┐
	│ Tests:        13                                                                               │
	│ Passing:      13                                                                               │
	│ Failing:      0                                                                                │
	│ Pending:      0                                                                                │
	│ Skipped:      0                                                                                │
	│ Screenshots:  0                                                                                │
	│ Video:        true                                                                             │
	│ Duration:     39 seconds                                                                       │
	│ Spec Ran:     productlist.js                                                                   │
	└────────────────────────────────────────────────────────────────────────────────────────────────┘


	(Video)

	-  Started processing:  Compressing to 32 CRF                                                     
	-  Finished processing: /var/lib/jenkins/workspace/my-project-production/cypress/vide    (6 seconds)
													os/productlist.js.mp4                                                     


────────────────────────────────────────────────────────────────────────────────────────────────────
																																																		
	Running:  search.js                                                                       (4 of 4)


	Basic product tests
		✓ Can search for product (7192ms)
		✓ Will load more products (5788ms)
		✓ Will go to search page on submit (7396ms)
		✓ Will show message when no results found (6996ms)

[loading]

Screenshots of htop on machine where test is hanging:

image

Versions

Version 6 (latest)

@simplenotezy simplenotezy changed the title Cypress takes forever to complete Cypress takes forever to complete / hangs during tests Nov 26, 2020
@olaj
Copy link

olaj commented Nov 27, 2020

I might have a similar issue. For me it hangs in CI but also when i run the test locally with a headless browser. It seems to work fine when i run it with "open".

I've also noticed that it runs fine with when i ran it with ".only", finally i just skipped another pretty insignificant test and it works now. No idea what is going on tbh.

I do use route2 / intercept in the test and i noticed sometimes that it worked when i removed the cy.wait([alias]) stuff.

I don't have the time to try to do a reproduction atm but i just want to ping here if more people have the same issue.

Ps. I've also updated from 5.x to 6.0 to see if that helped but same issue.

@Wharenn
Copy link

Wharenn commented Nov 27, 2020

Same issue in our case. Updating to 6 triggered most of the time infinite hangs (more than 1 day before we killed it). We are in early adoption of Cypress and we do not have complex tests. No usage of intercept or route. On several builds containing two parallel step of Cypress runs, it hanged sometimes in one step, sometimes on the other one. Multiple time we had the same step stuck but it did not block at the same test. So it seems not related to some kind of test content.

Here our output (without errors to be spotted):

====================================================================================================

  (Run Starting)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:    6.0.0                                                                              │
  │ Browser:    Chrome 83 (headless)                                                               │
  │ Specs:      3 found (tests/Admin/Product.feature, tests/Admin/Profile.feature, tests/Admin/Sho │
  │             oting/Create.feature)                                                              │
  │ Searched:   cypress/integration/**/Admin/**/*                                                  │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘

────────────────────────────────────────────────────────────────────────────────────────────────────

                                                                                                   
  Running:  tests/Admin/Product.feature                                                     (1 of 3)

Browserslist: caniuse-lite is outdated. Please run next command `yarn upgrade`

Reverting to Cypress 5.4 (our previous version) seems to fix the issue.

@jennifer-shehane
Copy link
Member

Can you provide a reproducible example? It's likely very specific to the tests and how they are written. We'll need that in order to investigate. Here are some tips for providing a Short, Self Contained, Correct, Example and our own Troubleshooting Cypress guide. Thanks!

@jennifer-shehane jennifer-shehane added the stage: needs information Not enough info to reproduce the issue label Nov 30, 2020
@Wharenn
Copy link

Wharenn commented Nov 30, 2020

We use https://github.com/TheBrainFamily/cypress-cucumber-preprocessor to write our tests in Gherkin, and we do some cookie preservation using before hooks. This is the only things I really see which could be specific to our tests. However, this was already the case in the 5.X implementation.

Is there any way to have logs to understand where it is really hanging?
As explained above, in our current problem, hangs occurs in mostly all tests, but sometimes does not occurs at all and tests are OK. It makes isolating the issue really difficult.

@olaj
Copy link

olaj commented Nov 30, 2020

FYI I do cookie preserving to, will see if i can manage to create a reproduction but have a lot to do atm and will live with some skipped tests for now.

@kuceb
Copy link
Contributor

kuceb commented Nov 30, 2020

if this is only happening in cypress run mode and not in open mode, it could be Cypress trying to mistakenly serialize a DOM node or the window object to send to the terminal reporter. We have safeguards around that but there may be another edge case. If we can get a reproducible there should be an obvious fix. Thanks

@Garreat
Copy link

Garreat commented Dec 4, 2020

I've been having similar issues, really weird behaviour for jenkins+docker+cypress combination.
I don't even know much about cypress, however --ipc=host and --shm-size=512m (or more) are essential for electron. That's for a start.
Now -- I've been able to fix the issue with abandoning the docker.image().inside{} pipeline contruction. It's actually is a dirty shell hack based on cat command. Perhaps cypress does some interactions with it's runtime environment which just don't work here.
So far this has been consistent to me. You could give it a try if you're using the docker.image().inside{} block for cypress calls.
This refers to scripted pipeline, I believe declarative pipeline docker calls also translate to .inside{}.

@bahunov
Copy link

bahunov commented Dec 5, 2020

My issue went away when I used electron instead of chrome inside docker container

@AlexanderTunick
Copy link

My issue went away when I used electron instead of chrome inside docker container

We use electron in Docker and it reproducing anyway. The only thing that I can say for now, that it gets reproduced in most of the cases when we run all the tests (it's more than 500) if running 3,14,101 then don't encounter the issue.

@bahunov
Copy link

bahunov commented Dec 10, 2020

My issue went away when I used electron instead of chrome inside docker container

We use electron in Docker and it reproducing anyway. The only thing that I can say for now, that it gets reproduced in most of the cases when we run all the tests (it's more than 500) if running 3,14,101 then don't encounter the issue.

Waw. 500? I'm just running approx under 50 cases.
Have you tried to invoke garbage collection in between after each?
Also, try to set numTestsKeptInMemory to 0 ..

@jennifer-shehane
Copy link
Member

Can anyone provide a reproducible example? Right now there doesn't seem to be enough information to reproduce the problem on our end. We'll have to close this issue if we can't reproduce it. This does not mean that your issue is not happening - it just means that we do not have a path to move forward.

Please comment in this issue with a reproducible example.

@tobiasweibel
Copy link

I can't really provide a reproducible example. We were able to resolve our issues by distributing the tests to more Jenkins nodes. So far we just had one and ran 2-3 cypress instances in parallel. Sometime it worked, sometimes it crashed without a good hint.

@anshulupadhyay19
Copy link

anshulupadhyay19 commented Jul 29, 2021

I observed the similar issue today, where Cypress hangs forever in headless mode. It took sometime to figure out a test which was causing the issue. When I disabled the test, it worked fine.

Basically the test checks that after logout, I should not go back to home page, by clicking back or forward button. I'm not sure which step was causing issue, but after disabling this test, everything worked fine.

homePage_PO.logout()

cy.log('press back button')
cy.go('back')
cy.url().should('include', loginPage_PO.loginPageUrl)

cy.log('press forward button')
cy.go('forward')
cy.url().should('include', loginPage_PO.loginPageUrl)

@istisiki
Copy link

istisiki commented Feb 2, 2022

Can confirm this is happening for us as well. Using Cypress 8.7.0 in Azure Devops.
Sometimes it runs under 6 minutes. Sometimes it's stuck at the first test and the pipeline times out.
Can't provide any meaningful reproduction steps as the issue seems intermittent.

@GlebkaF
Copy link

GlebkaF commented Apr 22, 2022

I ran into this problem after upgrading from 8 to 9.5.4

@cypress-bot cypress-bot bot added stage: backlog and removed stage: needs information Not enough info to reproduce the issue labels Apr 29, 2022
@mcat97
Copy link

mcat97 commented May 9, 2022

Confirming we're running into this as well with upgrading from 3 to 9.5.4.

Tests that weren't failing before we deleted a lot of useless ones are now failing consistently, they're handing on trying to load the first test, but the rest of the suite will pass without issue. It makes no sense.

cy:open runs without issue.

@emilyrohrbough
Copy link
Member

If any of you are still experiencing this issue, can you please run with DEBUG=cypress* to gather the verbose logs to see if additional information can be uncovered?

@bbernhard
Copy link

bbernhard pushed a commit to ImageMonkey/imagemonkey-core that referenced this issue Jul 8, 2022
@dwjohnston
Copy link

dwjohnston commented Aug 17, 2022

Just FYI, this is what this issue looks like for me in Buildkite:

[2022-08-15T09:20:36Z]   Running:  case-management/CaseActivity.e2e.test.ts                                       (3 of 15)
--
  | [2022-08-15T09:20:36Z]   Estimated: 5 minutes, 11 seconds
  | [2022-08-15T09:20:40Z]
  | [2022-08-15T09:20:40Z]
  | [2022-08-15T09:20:40Z]   Case Activity - Smoke Test
  | [2022-08-15T09:21:52Z]     ✓ Successfully create case comment (71288ms)
  | [2022-08-15T09:22:56Z]     ✓ Ctrl + enter form submission works (63601ms)
  | [2022-08-15T09:23:50Z]     ✓ Check stix field validation (53490ms)
  | [2022-08-15T09:25:27Z]     ✓ Check form field validation (96655ms)
  | [2022-08-15T09:25:27Z]
  | [2022-08-15T09:25:27Z]
  | [2022-08-15T09:25:27Z]   4 passing (5m)
  | [2022-08-15T09:25:27Z]
  | [2022-08-15T11:46:27Z]
  | [2022-08-15T11:46:27Z]   (Results)
  | [2022-08-15T11:46:27Z]
  | [2022-08-15T11:46:27Z]   ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  | [2022-08-15T11:46:27Z]   │ Tests:        4                                                                                │
  | [2022-08-15T11:46:27Z]   │ Passing:      4                                                                                │
  | [2022-08-15T11:46:27Z]   │ Failing:      0                                                                                │
  | [2022-08-15T11:46:27Z]

Note a large gap with apparently no activity between the tests reporting as passing 4 padding (5m) and the results showing (Results).

Environment info:

Cypress:        9.5.3 
Browser:        Electron 94 (headless)          
Node Version:   v14.17.0 (/usr/bin/node)

Upgraded to Cypress 9.7.0 and same issue.

@modern-sapien
Copy link

A hang regarding this may have been handled in Cypress 10.11.0

#24338

@rburgst
Copy link

rburgst commented Nov 16, 2022

Having exactly the same issue, at least according to github actions timestamps we have cypress pausing for several minutes between X passing (Ys) and (Results).

Tried upgrading to cypress 11.1.0 and this has not changed anything.

@rburgst
Copy link

rburgst commented Nov 16, 2022

Note that I switched from electron to chrome and now it seems to run much quicker and the delays seem to be gone.

@marinakuranda
Copy link

See this behaviour with version 12 now, on the slow connection a test hangs forever on the default blank page. Running in Chrome.

@amakhrov
Copy link

Is it the same as #8206, or are there meaningful differences between the two?

@nagash77
Copy link
Contributor

In order to give our engineers the best chance at recreating your problem, please create a reproducible example using a fork of Cypress Test Tiny. This gives us the best chance of seeing exactly what you are seeing and being able to investigate effectively. If we don't receive a way to exhibit this behavior we won't be able to move forward and will have to close this issue until we can reproduce this problem.

@nagash77
Copy link
Contributor

Unfortunately we have to close this issue due to inactivity.

@nagash77 nagash77 closed this as not planned Won't fix, can't repro, duplicate, stale Aug 16, 2023
@nagash77 nagash77 removed their assignment Aug 28, 2023
@NicestRudeGuy
Copy link

We are facing the same issue. The testcase gets stuck in a machine ( we have 14 ) ,Is there a option to see what is the current state of test in cypress cloud ?
We dont even get video of the stuck testcase.
It happens randomly and random testcases get stuck not the same one so its very difficult to know the reason @nagash77
Any help will be appriciated

@alvaro-s-oliveira
Copy link

We are also facing the same issue. Using the current cypress ver 13.7.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests