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 cy.screenshot() timeout during cypress run #5016

Closed
taylorpreston opened this issue Aug 21, 2019 · 202 comments · Fixed by #29038
Closed

Cypress cy.screenshot() timeout during cypress run #5016

taylorpreston opened this issue Aug 21, 2019 · 202 comments · Fixed by #29038
Assignees
Labels
CI General issues involving running in a CI provider E2E Issue related to end-to-end testing OS: linux prevent-stale mark an issue so it is ignored by stale[bot] topic: screenshots 📸

Comments

@taylorpreston
Copy link

Current behavior:

All of our tests pass locally, but when running the Codeship CI we get errors for a few tests.

The error during Codeship CI builds: CypressError: cy.screenshot() timed out waiting '30000ms' to complete.

Desired behavior:

All tests pass in Codeship CI

Steps to reproduce:

For our app the reproduction is running the ci:codeship command runs which calls cy:record
"cy:record": "cypress run --record --key *key* --config video=false", "ci:codeship": "start-server-and-test start http://localhost:5000 cy:record"

I'm not exactly sure how to reproduce this other than creating a Codeship Basic app and attempting to run tests there. I have seen a few other issues point to a problem with how Cypress and Codeship interact.

Versions

Cypress version: 3.4.1

Sidenote: We are using the cypress-autorecord package, but it doesn't seem like this is involved.

@lleewwiiss

This comment has been minimized.

@taylorpreston
Copy link
Author

@lleewwiiss We never figured out what was causing this issue. We think it has to do with cypress beginning to run tests on the application before it has finished starting. The errors we received were the first 2-5 tests.

@zeel

This comment has been minimized.

@justinpincar
Copy link

Also been getting this on 3.5.0 and 3.6.1.

@tibdex
Copy link

tibdex commented Dec 30, 2019

I also have this issue with 3.8.1 and Chrome 79 on CircleCI's ubuntu-1604:201903-01 machine. It's not there with Chrome 78 or the embedded version of Electron. It's probably related to #6023.

@jennifer-shehane jennifer-shehane changed the title Cypress cy.screenshot() timeout running in Codeship CI Cypress cy.screenshot() timeout running in certain CI provider environments Jan 31, 2020
@jennifer-shehane
Copy link
Member

  • Can you run Cypress in debug mode mode and print the entire set of logs here?
  • Can you provide the machine and machine version they are running into this issue with, that would be appreciated.
  • Provide the browser you are running within (Electron, Chrome + version).

I don't think this is related directly to #6023

@toneysum41

This comment has been minimized.

@leichteckig
Copy link

Hello,
I have the same issue starting with 3.8.2 (and above) currently. Cypress 3.8.1 works correctly though.

We're using cypress/included docker image in Gitlab CI and keep getting these error messages:

CypressError: cy.screenshot() timed out waiting '60000ms' to complete.

It won't appear in every test and I can't see a pattern in those fails yet. At the moment, I'm struggling with getting debug mode to run, but I'll give an update as soon as I can provide some logs. I hope this first information can help nevertheless. Thank you in advance for all help, information etc.!

@bgcypressqa
Copy link

bgcypressqa commented Feb 5, 2020

I can confirm with @leichteckig that this issue is occurring as described:

"... 3.8.2 (and above) currently. Cypress 3.8.1 works correctly though.

We're using cypress/included docker image in Gitlab CI and keep getting these error messages:

CypressError: cy.screenshot() timed out waiting '60000ms' to complete."

Only difference is that I am using Azure DevOps CI and their container services.

@teknologista
Copy link

teknologista commented Feb 5, 2020

I can alsoI confirm with @leichteckig that this issue is occurring as described.

We are using Gitlab CI with Ubuntu CI runners and your docker image cypress/browsers:node12.14.0-chrome79-ff71

CypressError: cy.screenshot() timed out waiting '60000ms' to complete."

random, masks errors also...It doesn't happen locally on desktop/laptop.

Glad I read through this to figure out downgrading to 3.8.1 would solve the issue.

@Powersource
Copy link

I am having some variation on this issue. It was just happening for one specific test. Was running 3.6.1 and upgraded to 3.8.1, didn't help. When running the test locally I could see the real reason that the test was failing (instead of the screenshot timeout like CI was claiming). So for me it was mostly an issue of a bad error message i CI.

@teknologista
Copy link

@Powersource exactly what I meant by sometimes it also masks the true reason for the test fail

@alexbjorlig
Copy link

I just upgraded Cypress to 4.0.1, and we now started to see tests failing on Github Actions with screenshot() timeout warning 😢

@jennifer-shehane jennifer-shehane changed the title Cypress cy.screenshot() timeout running in certain CI provider environments Cypress cy.screenshot() timeout during cypress run Feb 11, 2020
@jennifer-shehane
Copy link
Member

Need info

I still have questions that have gone unanswered in this thread that are necessary for investigation.

  • What browser are you running? What version of the browser?
  • Are you running with --headless flag?
  • What machine and machine version are you running?
  • Are you calling the cy.screenshot() command directly? Are you using a plugin that calls the cy.screenshot() command?

Chrome 79 bug?

There has been some speculation that this may be caused by the Chrome 79 performance bug detailed here: #6023 (comment)

If you are running on Chrome 79, we've released a docker image for Chrome 80 found here: https://github.com/cypress-io/cypress-docker-images/tree/master/browsers/node13.6.0-chrome80-ff72 at cypress/browsers:node13.6.0-chrome80-ff72.

Please try to update to using Chrome 80. If this is related to #6023 it may fix your issue.

@alexbjorlig
Copy link

Hi @jennifer-shehane.

Need info

I still have questions that have gone unanswered in this thread that are necessary for investigation.

  • What browser are you running? What version of the browser? Chrome 79.0.3945.130
  • Are you running with --headless flag? No
  • What machine and machine version are you running? ubuntu-16.04
  • Are you calling the cy.screenshot() command directly? Are you using a plugin that calls the cy.screenshot() command? no

Chrome 79 bug?

There has been some speculation that this may be caused by the Chrome 79 performance bug detailed here: #6023 (comment)

If you are running on Chrome 79, we've released a docker image for Chrome 80 found here: https://github.com/cypress-io/cypress-docker-images/tree/master/browsers/node13.6.0-chrome80-ff72 at cypress/browsers:node13.6.0-chrome80-ff72.

Please try to update to using Chrome 80. If this is related to #6023 it may fix your issue.

I tried using chrome 80 in my Github actions:

jobs:
  e2eTests:
    runs-on: ubuntu-16.04
    container: cypress/browsers:node13.6.0-chrome80-ff72

Using the above container seems to give errors like this, and all tests fails:

[HPM] Error occurred while trying to proxy request /graphql from localhost:4200 to http://localhost:1337 (ECONNREFUSED) (https://nodejs.org/api/errors.html#errors_common_system_errors)

Our setup is an Angular + Graphql Node.js Express application. Is there something special I need to make this work when running in containers - or do you want me to open that as a separate issue?

But screenshots seems to be working 🔥

@jennifer-shehane
Copy link
Member

@alexbjorlig Hmm, I haven't seen the ECONNREFUSED error for proxy requests before. Yeah, I would open a new issue. May be more due to the Node upgrade.

The fact that screenshots work in Chrome 80 is very promising though. Thanks for the update.

@alexbjorlig
Copy link

alexbjorlig commented Feb 12, 2020

@jennifer-shehane - thanks, I will create a new issue for the ECONNREFUSED.

Update
After looking at my logs, I can see that the problem is that our Node server uses a mongo in-memory server. This package has a problem, when running in docker, as described here.

Is there another way to run Cypress with Chrome80? I tried using runs-on: ubuntu-latest, (where the mongodb memory server works without issues), but here the Chrome version is 79 😢

Final update
My build now works with the Chrome80 container, you can see the details here.

@leichteckig
Copy link

Hello there,

A little update: I tried Cypress' docker images with Chrome 80 (Cypress 4.0.0 and newer) as recommended in #6023 (comment) and after a week or so, I don't see any more screenshot related failures until now.

In 3.8.2, there was Chrome 79 installed iirc. So it looks like it was the mentioned Chrome bug for me as well. Thank you so much for your advice! 👍

@jpike88
Copy link

jpike88 commented Mar 2, 2020

Just upgraded to cypress/browsers:node12.16.1-chrome80-ff73 and this has broken my test builds using Codebuild.

@Dale-777
Copy link

Dale-777 commented Feb 5, 2024

@jennifer-shehane we have this same issue with a single test, it occurs infrequently, and the reason it appears to be related to this test is the page under test in-particular is highly complex and no doubt is heavy to load & render, so until you have a way to simulate that you will not be able to reproduce this.

For us this error occurs in a feature file, with 8 scenarios, each loading the same page, so could be a memory issue.

cy.screenshot() timed out waiting 30000ms to complete.

Because this error occurred during a after each hook we are skipping all of the remaining tests.[Learn more](https://on.cypress.io/screenshot)
View stack trace
CypressError: `cy.screenshot()` timed out waiting `30000ms` to complete.

Because this error occurred during a `after each` hook we are skipping all of the remaining tests.
    at https://XXXX.com/__cypress/runner/cypress_runner.js:134337:73
    at tryCatcher (https://XXXX.com/__cypress/runner/cypress_runner.js:1807:23)

@jennifer-shehane jennifer-shehane added the stage: needs information Not enough info to reproduce the issue label Feb 5, 2024
@Tathos20
Copy link

Tathos20 commented Feb 6, 2024

We are running multiple feature files in Azure pipelines. We see this issue always at the first feature file. All of the others are okay. Hope this information hepls.

@eschutho
Copy link

We're able to reproduce this consistently in Apache Superset (open source). Here's a PR that shows the E2E CI failures and the test output. The screenshot timeout errors seem to be limited to these code changes, too, but they pass when running Cypress locally. CI is running Chrome 119 on Ubuntu - 20.04.

@jennifer-shehane
Copy link
Member

@eschutho Thanks for the repo! Any thoughts on updating to latest Cypress within those tests?

@jennifer-shehane
Copy link
Member

@eschutho Could you give the minimal instructions to get this up and running with Cypress tests? I tried to follow the contributing guidelines and am still running into:

(venv)  superset db upgrade
zsh: command not found: superset

Also I get this error when running

pip install -e .

Screenshot 2024-02-14 at 10 29 39 AM
Screenshot 2024-02-14 at 10 29 44 AM

@eschutho
Copy link

@eschutho Thanks for the repo! Any thoughts on updating to latest Cypress within those tests?

Hi, @jennifer-shehane yes, we're a little behind in our updates, but we are planning to upgrade this year.

Could you give the minimal instructions to get this up and running with Cypress tests?

You can use the make commands. make superset should install and build and make flask-app for backend make node-app for webpack. Once you have the app running, you can build/run cypress with:
make build-cypress and make open-cypress 9000

If you run into any issues with the make commands, it looks like with where you are currently, you'll need to run pip install -r requirements/local.txt and then follow the rest of the steps.

Alternatively there's a docker image that you can use. These are the instructions for running with Docker. https://github.com/apache/superset/blob/master/CONTRIBUTING.md?plain=1#L973

Happy to help with any other setup questions for reproducing.

@jennifer-shehane
Copy link
Member

jennifer-shehane commented Feb 16, 2024

@eschutho make superset is failing and the docker image exits also. I'll need an easier example to run since this is now taking significant time to run.
Screenshot 2024-02-16 at 11 16 57 AM

@droca
Copy link

droca commented Feb 21, 2024

We were facing this issue as well, only when running the tests on CI (Browserstack) and not all the time. These are our conclusions:

  • The cause of this issue was that some of our tests where clicking on buttons and links that were opening new tabs. We didn't do anything on the new tabs and it was not having any effect on the e2e tests running locally.

  • The 'solution' we applied was to 'hack' a bit the behaviour of the application under test to avoid the links / buttons from opening a new tab. We did it with this code on the appropriate place:

Cypress.$(element).on('click', e => {
  e.preventDefault()
})

As a caveat, this solution only works for the regular elements / buttons that contain an href, but it doesn't with the ones that are using the onClick function to redirect (like with a react push or something like that)

@jennifer-shehane
Copy link
Member

jennifer-shehane commented Feb 26, 2024

@droca I was able to recreate this situation. Only within the Chrome browser. This can be recreated with cypress open and cypress run.

test.js

it('click on new tab', () => {
  cy.visit('index.html')
  cy.get('a').click().should('have.attr', 'foo')
})

index.html

<html>
  <script>
  </script>
<body>
  <a target="_blank" href="new.html">Click me</a>
</body>
</html>

new.html

<html>
</html>

Screenshot 2024-02-26 at 11 15 38 AM

@jennifer-shehane jennifer-shehane added stage: investigating Someone from Cypress is looking into this and removed stage: needs information Not enough info to reproduce the issue labels Feb 28, 2024
@jennifer-shehane jennifer-shehane moved this from Understanding to Designing / Scoping in Cypress App Priorities Feb 28, 2024
@github-project-automation github-project-automation bot moved this from Designing / Scoping to Generally Available in Cypress App Priorities Mar 8, 2024
@jennifer-shehane jennifer-shehane removed the stage: investigating Someone from Cypress is looking into this label Mar 11, 2024
@cacieprins cacieprins reopened this Mar 11, 2024
@github-project-automation github-project-automation bot moved this from Generally Available to Building in Cypress App Priorities Mar 11, 2024
@github-project-automation github-project-automation bot moved this from Building to Generally Available in Cypress App Priorities Mar 11, 2024
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Mar 13, 2024

Released in 13.7.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v13.7.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Mar 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CI General issues involving running in a CI provider E2E Issue related to end-to-end testing OS: linux prevent-stale mark an issue so it is ignored by stale[bot] topic: screenshots 📸
Projects
None yet
Development

Successfully merging a pull request may close this issue.