Cypress: Cypress cy.screenshot() timeout during `cypress run`

Created on 21 Aug 2019  路  52Comments  路  Source: cypress-io/cypress

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.

circle codeship github actions gitlab linux needs information screenshots 馃摳

Most helpful comment

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

All 52 comments

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

@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.

I am also experiencing the same error.

Also been getting this on 3.5.0 and 3.6.1.

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.

  • 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 https://github.com/cypress-io/cypress/issues/6023

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

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.!

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.

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.

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.

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

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

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: 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.

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 馃敟

@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.

@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.

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:

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

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

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!

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.

@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

We're also seeing this on Chrome 80.

I have seen it today too, it was first time

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

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.

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.

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

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

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.

  • Setting "numTestsKeptInMemory": 0 may alleviate the problem
  • Some plugins utilizing console.log output may be interfering with the screenshot somehow, like cypress-failed-log or log-to-console-output
  • Restarting the device may help, as the device resources are an issue.

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)
  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.

Fwiw, we started getting "cy.screenshot() timed out waiting 30000ms to complete." when we went from [email protected] 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:

  • win10
  • electron headless via cypress run command

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.

Running into the same issue in our CI. It happens quite often. Using [email protected] 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)

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.

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

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));

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...

@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.

@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.

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

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

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

@jennifer-shehane Yes, alert asking for credentials.

@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.

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?

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.

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

@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.

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?

@jennifer-shehane When I run into this problem it was because the page that the screenshot was run on was rather long.
What caused me the most irritation was that the exception was thrown from inside the handling of a failed testcase, causing the test-case failure to be hidden. If there is an easy way to make sure that the test-failure is reported despite the screenshot (or anything else in the cleanup) failing, that would probably solve most of the irritation from this problem.

When we ran into this problem , we solved it by using a workaround by passing "screenshotOnRunFailure": false in your cypress.json file. In the scenario, the cypress doesn't try to capture the screenshot on failure and you get the actual error.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

szabyg picture szabyg  路  3Comments

jennifer-shehane picture jennifer-shehane  路  3Comments

carloscheddar picture carloscheddar  路  3Comments

dkreft picture dkreft  路  3Comments

igorpavlov picture igorpavlov  路  3Comments