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 runMode retry shows duplicate tests and getting stuck during run #14423

Closed
davidhu2000 opened this issue Jan 6, 2021 · 7 comments
Closed
Labels
stage: needs information Not enough info to reproduce the issue stale no activity on this issue for a long period topic: test retries ♻️

Comments

@davidhu2000
Copy link

davidhu2000 commented Jan 6, 2021

I am truly stumped with this issue. We occasionally have an issue where our site doesn't load during a few tests.

We would see this error

     CypressError: Timed out after waiting `60000ms` for your remote page to load.

Your page did not fire its `load` event within `60000ms`.

You can try increasing the `pageLoadTimeout` value in `cypress-qa.json` to wait longer.

Browsers will not fire the `load` event until all stylesheets and scripts are done downloading.

So we thought maybe adding retry would help with the issue.

  "retries": {
    "runMode": 2,
    "openMode": 0
  },

so we added this into cypress.json.

Current behavior

 User Modal

    on page load

      (Attempt 1 of 3) should not render the user modal

      (Attempt 1 of 3) should not render the user modal

We would see an output like this, where the (Attempt 1 of 3) is duplicated. Then the test gets completely stuck. I left a run overnight, and 10 hours later, it still didn't move forward.

Desired behavior

Running retry locally works fine. We would see Attempt 1 then 2 and 3.

Test code to reproduce

The test is stuck when we are running on jenkins inside of docker images build from cypress/included:6.2.1.

This tricky part is that this error only happens sporadically on random tests. I tried to add DEBUG=cypress:* but that added so much log I couldn't load it all. If there is any specific I can output for the debug variable, please let me know.

Toward the end of the output, we just see the profiler over and over again.

  cypress:server:util:process_profiler current & mean memory and CPU usage by process group:
  cypress:server:util:process_profiler ┌─────────┬───────────────────┬──────────────┬─────────────────────────────────────────────────┬────────────┬────────────────┬──────────┬──────────────┬─────────────┐
  cypress:server:util:process_profiler │ (index) │       group       │ processCount │                      pids                       │ cpuPercent │ meanCpuPercent │ memRssMb │ meanMemRssMb │ maxMemRssMb │
  cypress:server:util:process_profiler ├─────────┼───────────────────┼──────────────┼─────────────────────────────────────────────────┼────────────┼────────────────┼──────────┼──────────────┼─────────────┤
  cypress:server:util:process_profiler │    0    │     'Chrome'      │      11      │ '262, 267, 268, 270, 290, 271 ... 5 more items' │   11.21    │     13.27      │  822.02  │    811.36    │   843.38    │
  cypress:server:util:process_profiler │    1    │     'cypress'     │      1       │                      '19'                       │    0.43    │      2.02      │  261.58  │    256.26    │   262.65    │
  cypress:server:util:process_profiler │    2    │ 'electron-shared' │      4       │               '27, 183, 28, 202'                │     0      │       0        │  178.9   │    181.14    │   384.61    │
  cypress:server:util:process_profiler │    3    │     'plugin'      │      1       │                      '250'                      │     0      │      0.31      │  167.98  │    166.42    │   167.98    │
  cypress:server:util:process_profiler │    4    │      'other'      │      2       │                  '2446, 2447'                   │     0      │       0        │   3.4    │      6       │   136.46    │
  cypress:server:util:process_profiler │    5    │      'TOTAL'      │      19      │                       '-'                       │   11.64    │     15.07      │ 1433.88  │   1387.01    │   1455.75   │
  cypress:server:util:process_profiler └─────────┴───────────────────┴──────────────┴─────────────────────────────────────────────────┴────────────┴────────────────┴──────────┴──────────────┴─────────────┘ +10s
docker run --name e2e-test --rm -v $PWD:/e2e -w /e2e --ipc=host -e CYPRESS_BASE_URL=http://host.docker.internal:3001 -e CYPRESS_VIDEO=true cypress/included:6.2.1

Running the command can sometimes reproduce the issue running against a local server. looking at my application logs locally, it does look like the tests actually finished. It is just not continuing. I suspect somehow due to the duplicate test output? It doesn't just happen on attempt 1 either, I have seen it happen on attempt 2 as well.

Screen Shot 2021-01-05 at 8 15 59 PM

The screenshot just shows a gray screen (which is not part of our application. If a page doesn't load, it should show a white background.)

What's interesting is the screenshot names that is generated off of one test

Page Name -- user with no role -- should update the page -- should go to the base account url if they click the button (failed)

should go to the base account url if they click the button -- after each hook (failed)

Even though our tests do not have an afterEach. The screenshot with the fully name has the gray blank page, while the after each screenshot has a white background.

We tried increasing timeout to 120 seconds, and still see the same issue.

I think the way to reproduce to run cypress in docker headless chrome/electron for a large test suite.

We are using Rails 5.1.4, ruby 2.4.9. With a react frontend, so the page loads, then load the javascript parts to render.

Versions

6.2.1
5.4.0

@davidhu2000 davidhu2000 changed the title Cypress runMode retry shows duplicate tests and get during run Cypress runMode retry shows duplicate tests and getting stuck during run Jan 6, 2021
@jennifer-shehane
Copy link
Member

We recently released a fix affecting retries. But this has also been happening in Cypress 5.4.0 right?

You mention:

I think the way to reproduce to run cypress in docker headless chrome/electron for a large test suite.

  • What do you mean by 'large test suite' exactly?
  • Is this failing on the same tests? Or is it random where it fails?
  • Regarding the afterEach hook - you don't have this defined anywhere? Not even a global one in any of the support files? I feel like this is the best lead in the issue.

I see you're already setting ipc=host like mentioned here #350 (comment)

@jennifer-shehane jennifer-shehane added the stage: needs information Not enough info to reproduce the issue label Jan 6, 2021
@davidhu2000
Copy link
Author

davidhu2000 commented Jan 6, 2021

yeah, it was happening on 5.4.0. I saw the fix in 6.2.1 so I updated and it is still happening.

What do you mean by 'large test suite' exactly?

we are running on a suite of about 300 tests. Altho I don't think this is a requirement, I'm really not sure when this happens.

Is this failing on the same tests? Or is it random where it fails?

It's random where it fails. Some times it happens on the first test, some times happening after a few suites. I don't see any pattern on when it happens.

Regarding the afterEach hook - you don't have this defined anywhere? Not even a global one in any of the support files? I feel like this is the best lead in the issue.

I did a search for afterEach for the cypress folder, only found 2 cases in a single test suite where we click a log out link. I removed those and it still happens. I don't see any other afterEach.

In our plugins file, we have this (if this is helpful.

on('before:browser:launch', (browser, launchOptions) => {
    if (browser.name === 'chrome') {
      launchOptions.args.push('--disable-dev-shm-usage');
    }
    return launchOptions;
  });

I see you're already setting ipc=host like mentioned here #350 (comment)

So i'm using the command during my local testing. I'm not sure if we are using that on our jenkins server. Although I don't think having ipc=host matters too much in this case, as we see the issue with it or without.

I tried running the same thing on one of our older jenkins servers

org.jenkins-ci.main:jenkins-war:2.107.2
Docker version 18.06.0-ce, build 0ffa825

That seems to work fine.

The one we are having trouble with is

org.jenkins-ci.main:jenkins-war:2.255
Docker version 20.10.0, build 7287ab3

@jennifer-shehane
Copy link
Member

I'm not really sure how much more we can investigate without a way to reproduce it. Is it possible to narrow down the issue anymore? Commenting out suites/tests?

@davidhu2000
Copy link
Author

I'll see if i can come up with a reproducible example to help track this down.

@deebandrawis
Copy link

same problem here, If you managed to solve it, I'll be more than happy if you share the solution .

@adambullmer
Copy link

adambullmer commented Aug 26, 2022

My two cents here is that there could be an improvement to the component tests where cypress waits for the bundler to finish before trying to load in the test suites, or before it tries to run the first test in the detected suites, as anecdotally there seems to be a bug in the retry logic that has some cascading errors. Additionally, running the same setup in cypress 9 with component tests didn't have the same issue, so there might have been a regression in the major version update to 10.

Some context that may help reproducibility:

Cypress Version: 10.3.1
Project Type: vue-cli
Bundler: webpack
Runtime Environment: Mac (inten chip) -> docker
Docker Command: docker run --rm -it -v `pwd`:/opt/app --workdir /opt/app cypress/included:10.3.1 --component --headless
Sample Output:

$ docker run --rm -it -v `pwd`:/opt/app --workdir /opt/app cypress/included:10.3.1 --component --headless
libva error: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null)
[212:0826/142634.835591:ERROR:sandbox_linux.cc(377)] InitializeSandbox() called with multiple threads in process gpu-process.
[212:0826/142634.840605:ERROR:gpu_memory_buffer_support_x11.cc(44)] dri3 extension not supported.
[@cypress/webpack-dev-server]: removing CaseSensitivePathsPlugin from configuration.
[@cypress/webpack-dev-server]: removing HtmlWebpackPlugin from configuration.
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: http://127.0.0.1:8080/
<i> [webpack-dev-server] Content not from webpack is served from '/opt/app/public' directory

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

  (Run Starting)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:        10.3.1                                                                         │
  │ Browser:        Electron 100 (headless)                                                        │
  │ Node Version:   v16.14.2 (/usr/local/bin/node)                                                 │
  │ Specs:          1 found (login.spec.ts)                                                        │
  │ Searched:       tests/cypress/specs/component/**/*.spec.ts                                     │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


────────────────────────────────────────────────────────────────────────────────────────────────────
                                                                                                    
  Running:  login.spec.ts                                                                  (1 of 11)
<i> [webpack-dev-middleware] wait until bundle finished: /__cypress/src/index.html

Timed out waiting for the browser to connect. Retrying...
<i> [webpack-dev-middleware] wait until bundle finished: /__cypress/src/index.html

Timed out waiting for the browser to connect. Retrying again...
 DONE  Compiled successfully in 138691ms2:29:22 PM

42 assets
1747 modules
webpack 5.70.0 compiled successfully in 138691 ms
No issues found.


  ConsumerLogin.vue
    Next Button

      

        
          ConsumerLogin.vue
            Next Button
              ConsumerLogin.vue
                Next Button
                  ✓ starts disabled (680ms)
                  ✓ starts disabled (802ms)
                  ✓ starts disabled (1000ms)
                  ✓ is disabled with an invalid email input (1155ms)
                  ✓ is disabled with an invalid email input (1135ms)
                  ✓ is disabled with an invalid email input (1002ms)
                  ✓ does not continue with invalid email input (933ms)
                  ✓ does not continue with invalid email input (1150ms)
                  ✓ does not continue with invalid email input (1471ms)
                  ✓ is enabled with a valid email input (1107ms)
                  ✓ is enabled with a valid email input (1045ms)
                  ✓ is enabled with a valid email input (927ms)
                  ✓ continues with a valid email input (1064ms)
                  ✓ continues with a valid email input (1104ms)
                  ✓ continues with a valid email input (1009ms)
                  ✓ includes the email from the first step into the second form (1298ms)
                Submit Button
                  ✓ includes the email from the first step into the second form (1356ms)
                Submit Button
                  ✓ includes the email from the first step into the second form (1174ms)
                Submit Button
                  ✓ does not submit when no password is entered (1256ms)
                  ✓ does not submit when no password is entered (1364ms)
                  ✓ does not submit when no password is entered (1338ms)
                  ✓ sends a request when clicked with a valid password (1948ms)
                  ✓ sends a request when clicked with a valid password (1833ms)
                  ✓ sends a request when clicked with a valid password (2085ms)
                  ✓ is disabled while login is in progress (1749ms)
                  ✓ is disabled while login is in progress (1799ms)
                  ✓ is disabled while login is in progress (1974ms)
                  ✓ blurs the password field after pressing enter to submit the form (1614ms)
                  ✓ blurs the password field after pressing enter to submit the form (1661ms)
                  ✓ blurs the password field after pressing enter to submit the form (1677ms)
                  ✓ remains enabled after a user comes back with a different email (2420ms)
                  ✓ remains enabled after a user comes back with a different email (2385ms)
                  ✓ remains enabled after a user comes back with a different email (2328ms)
                  ✓ remains enabled after a user comes back with a different email and begins typing a password (2658ms)
                  ✓ remains enabled after a user comes back with a different email and begins typing a password (2567ms)
                  ✓ remains enabled after a user comes back with a different email and begins typing a password (2662ms)
                user eventing
                user eventing
                user eventing
                  ✓ Sends an event on auth start when the form is valid (1593ms)

  37 passing (20s)

            ✓ Sends an event on auth start when the form is valid (1689ms)
            ✓ Sends an event on auth start when the form is valid (1818ms)

While I'm referencing a convenience image here, I find it just as reproducible with a project specific official node image as well and referencing cypress as a a vue-cli plugin runtime as well. The biggest factor I see here is that docker's shared volume performance right now is considerably slower than running purely in docker, or purely on the host machine. So by mounting in the working dir as a volume for convenience, you can force a build that takes over the general 30s timeout and reproduce the duplicated tests on the first test suite.

As a side note, I also see occasionally that in this situation, there is also a fatal reporter, or fatal runtime error because of the erroneous concurrent test suite executions.

For example:

  Running:  login.spec.ts                                                                   (1 of 1)
<i> [webpack-dev-middleware] wait until bundle finished: /__cypress/src/index.html

Timed out waiting for the browser to connect. Retrying...
<i> [webpack-dev-middleware] wait until bundle finished: /__cypress/src/index.html
 DONE  Compiled successfully in 119906ms2:34:17 PM

13 assets
1737 modules
webpack 5.70.0 compiled successfully in 119906 ms
No issues found.



  
    ConsumerLogin.vue
      Next Button
        ConsumerLogin.vue
          Next Button
            ✓ starts disabled (578ms)

Timed out waiting for the browser to connect. Retrying again...
            ✓ starts disabled (719ms)
            1) "before each" hook for "is disabled with an invalid email input"
            2) "before each" hook for "is disabled with an invalid email input"

  2 passing (955ms)
  2 failing

  1) ConsumerLogin.vue
       Next Button
         "before each" hook for "is disabled with an invalid email input":
     Error: Could not process 'take:screenshot'. No automation clients connected.

Because this error occurred during a `before each` hook we are skipping the remaining tests in the current suite: `ConsumerLogin.vue`
      at SocketCt.onAutomation (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/lib/socket-base.js:88:15)
      at onAutomationClientRequestCallback (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/lib/socket-base.js:134:25)
      at /root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/lib/automation/automation.js:77:20
      at Promise.cancellationExecute [as _execute] (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/debuggability.js:406:9)
      at Promise._resolveFromExecutor (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise.js:518:18)
      at new Promise (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise.js:103:10)
      at Automation.requestAutomationResponse (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/lib/automation/automation.js:62:16)
      at /root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/lib/automation/automation.js:58:52
      at Object.capture (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/lib/screenshots.js:416:14)
      at Object.capture (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/lib/automation/screenshot.js:9:42)
      at /root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/lib/automation/automation.js:93:44
      at tryCatcher (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
      at Function.Promise.attempt.Promise.try (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/method.js:39:29)
      at Automation.normalize (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/lib/automation/automation.js:90:38)
      at /root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/lib/automation/automation.js:153:25
      at tryCatcher (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
      at Promise._settlePromiseFromHandler (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise.js:547:31)
      at Promise._settlePromise (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise.js:604:18)
      at Promise._settlePromiseCtx (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise.js:641:10)
      at _drainQueueStep (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/async.js:97:12)
      at _drainQueue (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/async.js:86:9)
      at Async._drainQueues (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/async.js:102:5)
      at Immediate.Async.drainQueues [as _onImmediate] (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/async.js:15:14)
      at processImmediate (node:internal/timers:464:21)
  

  2) ConsumerLogin.vue
       Next Button
         "before each" hook for "is disabled with an invalid email input":
     Error: Could not process 'take:screenshot'. No automation clients connected.

Because this error occurred during a `before each` hook we are skipping the remaining tests in the current suite: `ConsumerLogin.vue`
      at SocketCt.onAutomation (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/lib/socket-base.js:88:15)
      at onAutomationClientRequestCallback (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/lib/socket-base.js:134:25)
      at /root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/lib/automation/automation.js:77:20
      at Promise.cancellationExecute [as _execute] (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/debuggability.js:406:9)
      at Promise._resolveFromExecutor (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise.js:518:18)
      at new Promise (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise.js:103:10)
      at Automation.requestAutomationResponse (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/lib/automation/automation.js:62:16)
      at /root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/lib/automation/automation.js:58:52
      at Object.capture (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/lib/screenshots.js:416:14)
      at Object.capture (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/lib/automation/screenshot.js:9:42)
      at /root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/lib/automation/automation.js:93:44
      at tryCatcher (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
      at Function.Promise.attempt.Promise.try (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/method.js:39:29)
      at Automation.normalize (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/lib/automation/automation.js:90:38)
      at /root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/lib/automation/automation.js:153:25
      at tryCatcher (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
      at Promise._settlePromiseFromHandler (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise.js:547:31)
      at Promise._settlePromise (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise.js:604:18)
      at Promise._settlePromiseCtx (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise.js:641:10)
      at _drainQueueStep (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/async.js:97:12)
      at _drainQueue (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/async.js:86:9)
      at Async._drainQueues (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/async.js:102:5)
      at Immediate.Async.drainQueues [as _onImmediate] (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/async.js:15:14)
      at processImmediate (node:internal/timers:464:21)

Also an example of the error thrown by the reporter with duplicated tests:

Invalid array length
RangeError: Invalid array length
    at Runner.runner._events.pass.<computed> (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/lib/reporter.js:314:11)
    at Runner.emit (node:events:402:35)
    at Runner.emit (node:domain:475:12)
    at Reporter.emit (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/lib/reporter.js:362:46)
    at Object.onMocha (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/lib/project-base.js:283:34)
    at Socket.<anonymous> (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/server/lib/socket-base.js:251:40)
    at Socket.emit (node:events:390:28)
    at Socket.emit (node:domain:475:12)
    at Socket.emitUntyped (/root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/socket/node_modules/socket.io/dist/typed-events.js:69:22)
    at /root/.cache/Cypress/10.3.1/Cypress/resources/app/packages/socket/node_modules/socket.io/dist/socket.js:428:39
    at processTicksAndRejections (node:internal/process/task_queues:78:11)

@cypress-app-bot
Copy link
Collaborator

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

@cypress-app-bot cypress-app-bot added the stale no activity on this issue for a long period label May 17, 2023
@cypress-app-bot cypress-app-bot closed this as not planned Won't fix, can't repro, duplicate, stale May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage: needs information Not enough info to reproduce the issue stale no activity on this issue for a long period topic: test retries ♻️
Projects
None yet
Development

No branches or pull requests

5 participants