cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.7k stars 3.16k forks source link

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

Closed taylorpreston closed 6 months ago

taylorpreston commented 5 years ago

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 commented 4 years ago

@taylorpreston Did you ever resolve this issue? I am experience similar problems

taylorpreston commented 4 years ago

@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 commented 4 years ago

I am also experiencing the same error.

justinpincar commented 4 years ago

Also been getting this on 3.5.0 and 3.6.1.

tibdex commented 4 years ago

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 commented 4 years ago

I don't think this is related directly to https://github.com/cypress-io/cypress/issues/6023

toneysum41 commented 4 years ago

@taylorpreston I meet the same issue, did you find out the solution for this issue?

leichteckig commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

alexbjorlig commented 4 years ago

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 commented 4 years ago

Need info

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


Chrome 79 bug?

There has been some speculation that this may be caused by the Chrome 79 performance bug detailed here: https://github.com/cypress-io/cypress/issues/6023#issuecomment-584472171

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 commented 4 years ago

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 commented 4 years ago

@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 commented 4 years ago

@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 commented 4 years ago

Hello there,

A little update: I tried Cypress' docker images with Chrome 80 (Cypress 4.0.0 and newer) as recommended in https://github.com/cypress-io/cypress/issues/6023#issuecomment-584472171 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! :+1:

jpike88 commented 4 years ago

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

Undistraction commented 4 years ago

We're seeing this on Chrome 80.0.3987.122 (Official Build) (64-bit)

rhzs commented 4 years ago

I have observed two different behaviors in MacOS Mojave with Node JS 13 and Chrome v80.

  1. Running directly cypress run --browser chrome, you will get a lot of timeouts. If it occurs once, then the next screenshot command will follow.
  2. Running indirectly via cypress open then, select chrome browser. It successfully completes the tests.

This is weird!

Legendofire commented 4 years ago

I have observed two different behaviors in MacOS Mojave with Node JS 13 and Chrome v80.

  1. Running directly cypress run --browser chrome, you will get a lot of timeouts. If it occurs once, then the next screenshot command will follow.
  2. Running indirectly via cypress open then, select chrome browser. It successfully completes the tests.

This is weird!

We have had a similar issue, restarting our devices seemed to solve this particular issue so i assume it's device resources related.

lleewwiiss commented 4 years ago

@rhzs I believe this is due to some memory leak in caching test information. We have observed the same thing on machines with less ram (<=8GB. Setting "numTestsKeptInMemory": 0 fixed it for us, but that makes debugging more difficult

mingyixu commented 4 years ago

We're also seeing this on Chrome 80.

kamiloski commented 4 years ago

I have seen it today too, it was first time

shivasrini commented 4 years ago

Seeing this when using the 4.2.0 included docker image. Tried reverting back to an older image 3.8.1 and I am still seeing it. It started happening when I tried to use log-to-console-output and I cant make it go away even when I have removed all references to it

davojta commented 4 years ago

I have the same problem with cypress 4.2.0 with electron browser running on TravisCI on ubuntu I run locally in docker with 800mb and cant reproduce the issue.

davojta commented 4 years ago

Seems that problem is solved on Travis CI when I have start the cypress with --headless --browser chrome params. The chrome version is 73 in Travis CI.

davojta commented 4 years ago

Hm... It seems that setting numTestsKeptInMemory to 0 helps me and it is working with chrome 80 in Travis.

saas2813 commented 4 years ago

I'm getting this problem on a Mac in the Electron browser. I have a rather long page and the problem disappeared when I removed the cypress-failed-log plugin. I'm gonna have to try the other recommended plugin to work around the Issue "Capture + Display all logs for everything that happens in Cypress"

448

jennifer-shehane commented 4 years ago

Still need some info on this one, as we've never encountered this error on any of our runs across CI. Some thoughts from others in this thread.

rubin55 commented 4 years ago

Hi @jennifer-shehane, I have two questions:

  1. what are other consequences of setting numTestsKeptInMemory to 0? Is it still possible for cy.screenshot() to work when there are no tests kept in memory?
  2. If anything other than cypress is outputting to stdout, will that interfere with cy.screenshot()? (why would that be)
jennifer-shehane commented 4 years ago
  1. cy.screenshot() will still work with numTestsKeptInMemory set to 0. Setting this to 0 makes it so that the application under test will not be 'restored' when you hover or click on a command as explained here: https://on.cypress.io/test-runner#Hovering-on-Commands
  2. I don't know of any situation where this would occur or why this would interfere.
JohnnyFun commented 4 years ago

Fwiw, we started getting "cy.screenshot() timed out waiting 30000ms to complete." when we went from cypress@5.0.0 to 5.1.0. Reverting back to 5.0.0 seems to resolve so far.

We don't call cy.screenshot directly in any of our tests.

Running on:

I'll let you know if I see any patterns. Seems to happen on the same 3 or so tests, but not every run, and I don't think there's anything particularly special about them.

amejiarosario commented 3 years ago

Running into the same issue in our CI. It happens quite often. Using cypress@3.8.1 and CI is using Linux (CentOS).

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

Full stack trace:

  1) NetOps Report
       Validate charts
         should load charts for 90 day time range:
     CypressError: cy.screenshot() timed out waiting '30000ms' to complete.
      at Object.cypressErr (https://ci.dev.lockhart.io/__cypress/runner/cypress_runner.js:86089:11)
      at Object.throwErr (https://ci.dev.lockhart.io/__cypress/runner/cypress_runner.js:86044:18)
      at Object.throwErrByPath (https://ci.dev.lockhart.io/__cypress/runner/cypress_runner.js:86076:17)
      at https://ci.dev.lockhart.io/__cypress/runner/cypress_runner.js:72522:21
      at tryCatcher (https://ci.dev.lockhart.io/__cypress/runner/cypress_runner.js:120353:23)
      at https://ci.dev.lockhart.io/__cypress/runner/cypress_runner.js:115494:41
      at tryCatcher (https://ci.dev.lockhart.io/__cypress/runner/cypress_runner.js:120353:23)
      at Promise._settlePromiseFromHandler (https://ci.dev.lockhart.io/__cypress/runner/cypress_runner.js:118289:31)
      at Promise._settlePromise (https://ci.dev.lockhart.io/__cypress/runner/cypress_runner.js:118346:18)
      at Promise._settlePromise0 (https://ci.dev.lockhart.io/__cypress/runner/cypress_runner.js:118391:10)
      at Promise._settlePromises (https://ci.dev.lockhart.io/__cypress/runner/cypress_runner.js:118466:18)
      at Async../node_modules/bluebird/js/release/async.js.Async._drainQueue (https://ci.dev.lockhart.io/__cypress/runner/cypress_runner.js:115078:16)
      at Async../node_modules/bluebird/js/release/async.js.Async._drainQueues (https://ci.dev.lockhart.io/__cypress/runner/cypress_runner.js:115088:10)
      at Async.drainQueues (https://ci.dev.lockhart.io/__cypress/runner/cypress_runner.js:114962:14)
rhzs commented 3 years ago

Hi again Cypress team!

It seems, it is getting weirder and more unreliable than 6 months ago since I used the cy.screenshot. Now I often get the 30000ms timeout.

Please help :'(. It is one of the features what made me using Cypress.

arvinderloyalty commented 3 years ago

Hey, I am also facing this issue. Any updates?

LyesAtt commented 3 years ago

Hi people,

I came across the same problem, the screenshot was taking to much time and timed out my program resulting with an error.

Here's how I fixed it : cy.screenshot('screenshot', clearTimeout(number));

bluepioupiou commented 3 years ago

Same here, it seems to be a little chaotic : sometimes all goes well, and sometimes a few tests are failing with the 30000ms timeout. The screenshot stay stuck on the bottom of the page and timeout...

davidwallacejackson commented 3 years ago

@jennifer-shehane could you elaborate on how plugins using log output could cause this? I've started to see the issue as well, and I recently implemented a custom logging plugin. I'd be happy to instrument my test runs to help you collect data if you can tell me what'd be useful.

jennifer-shehane commented 3 years ago

@davidwallacejackson I'm not exactly sure why those would interfere, just that some other users indicated that those plugins may be causing the issue. We still need a clear reproducible way to reproduce this provided.

arvinderloyalty commented 3 years ago

For me, the reason why it was happening, there was a browser alert which was not handle and hence the test failed but cypress was not able to take the screenshot and hence it finally failed saying cy.screenshot() timeout

jennifer-shehane commented 3 years ago

@arvinderloyalty That makes sense. Like a normal Window alert?

arvinderloyalty commented 3 years ago

@arvinderloyalty That makes sense. Like a normal Window alert?

@jennifer-shehane Yes, alert asking for credentials.

harini910 commented 3 years ago

@jennifer-shehane I'm also facing the same issue CypressError: cy.screenshot() timed out waiting 30000ms to complete. I am running my cypress tests locally and here are the versions,

"cypress": "^5.2.0", "mocha": "^5.2.0", "mochawesome": "^4.1.0", "mochawesome-merge": "^2.0.1", "mochawesome-report-generator": "^4.0.1",

running in chrome 86 I am trying to integrate screenshots to failed test cases in mochawesome report and as the screenshot is failing Iam unable to do it, please do help me on this and if there is any workaround please suggest.

harini910 commented 3 years ago

Hi people,

I came across the same problem, the screenshot was taking to much time and timed out my program resulting with an error.

Here's how I fixed it : cy.screenshot('screenshot', clearTimeout(number));

@LyesAtt - where did you add this line of code?

LyesAtt commented 3 years ago

In the spec.js file.

Is where I tell cypress everything it need to do.

But still sometimes, Cypress error screenshot timeout and get a failed. So the only thing is to ignore the error.

harini910 commented 3 years ago

@LyesAtt - Thank you :) I will try and update.

leonidesfernando commented 3 years ago

@jennifer-shehane I'm also facing the same issue CypressError: cy.screenshot() timed out waiting 30000ms to complete. I am running my cypress tests locally and here are the versions,

"cypress": "^5.2.0", "mocha": "^5.2.0", "mochawesome": "^4.1.0", "mochawesome-merge": "^2.0.1", "mochawesome-report-generator": "^4.0.1",

running in chrome 86 I am trying to integrate screenshots to failed test cases in mochawesome report and as the screenshot is failing Iam unable to do it, please do help me on this and if there is any workaround please suggest.

I'm getting the same issue CypressError: cy.screenshot() timed out waiting 30000ms to complete.

Running my cypress tests locally and here are the versions,

"mocha": "^8.2.0",
"mochawesome": "^6.1.1",
"mochawesome-merge": "^4.2.0",
"mochawesome-report-generator": "^5.1.0",
"cypress": ">=5.5.0"

And also trying to integrate screenshots to failed test cases in mochawesome report and as the screenshot is failing.

BillyPapa commented 3 years ago

Hi,

@jennifer-shehane I am using Cypress with Chrome and only recently noticed (last few weeks) we keep getting the Error -

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

Code used: cy.screenshot('Screen-shot-name');

"cypress": "^3.8.0",
"cypress-cucumber-preprocessor": "2.0.1",
"cypress-iframe": "^1.0.1",

The issue is intermittent but fails and gets the Error about 90% of the time.

Chrome version: 86.0.4240.183 (Official Build) (64-bit)

Is there an ETA when this Bug will be sorted?