cypress icon indicating copy to clipboard operation
cypress copied to clipboard

Bizarre error when running cypress against a Grafana container - too much recursion

Open jesperancinha opened this issue 1 year ago • 1 comments

Current behavior

I have cypress running all 4 main browsers supported by Cypress: Electron, Chrome, Firefox, and Edge. I have never run into any issue using Cypress until the past few days where I think this is something to look at, wherewith Firefox and only firefox and only against a Grafana image, I get a bizarre recursion error. My project is not critical because I have it already running with Electron, Chrome, and Edge and I can run it locally without this exception ever occurring when manually interacting with the deployed version. However, it would be great if you could figure out what is going on. I'm not entirely sure if I'm missing something in my tests. I could be, but I'm not sure. This is what I'm getting:

moving-objects-service-root-e2e-firefox-1  |                                                                                                     
moving-objects-service-root-e2e-firefox-1  |   Running:  grafana.cy.ts                                                                  (4 of 10)
moving-objects-service-root-e2e-firefox-1  | 
moving-objects-service-root-e2e-firefox-1  | 
moving-objects-service-root-e2e-firefox-1  |   Grafana Tests
moving-objects-service-root-e2e-firefox-1  |     1) show grafana
moving-objects-service-root-e2e-firefox-1  | 
moving-objects-service-root-e2e-firefox-1  | 
moving-objects-service-root-e2e-firefox-1  |   0 passing (24s)
moving-objects-service-root-e2e-firefox-1  |   1 failing
moving-objects-service-root-e2e-firefox-1  | 
moving-objects-service-root-e2e-firefox-1  |   1) Grafana Tests
moving-objects-service-root-e2e-firefox-1  |        show grafana:
moving-objects-service-root-e2e-firefox-1  |      InternalError: too much recursion
moving-objects-service-root-e2e-firefox-1  |   cyContainsSelector@http://grafana:3000/__cypress/runner/cypress_runner.js:183198:19
moving-objects-service-root-e2e-firefox-1  |   ../driver/node_modules/jquery/dist/jquery.js/</elementMatcher/Sizzle<@http://grafana:3000/__cypress/runner/cypress_runner.js:107360:22
moving-objects-service-root-e2e-firefox-1  |   superMatcher@http://grafana:3000/__cypress/runner/cypress_runner.js:107581:19
moving-objects-service-root-e2e-firefox-1  |   ../driver/node_modules/jquery/dist/jquery.js/</Sizzle.select@http://grafana:3000/__cypress/runner/cypress_runner.js:107760:44
moving-objects-service-root-e2e-firefox-1  |   Sizzle@http://grafana:3000/__cypress/runner/cypress_runner.js:105928:9
moving-objects-service-root-e2e-firefox-1  |   find@http://grafana:3000/__cypress/runner/cypress_runner.js:107959:11
moving-objects-service-root-e2e-firefox-1  |   ../driver/node_modules/jquery/dist/jquery.js/</jQuery.fn.init@http://grafana:3000/__cypress/runner/cypress_runner.js:108074:40
moving-objects-service-root-e2e-firefox-1  |   query@http://grafana:3000/__cypress/runner/cypress_runner.js:184007:10
moving-objects-service-root-e2e-firefox-1  |   $$@http://grafana:3000/__cypress/runner/cypress_runner.js:162691:65
moving-objects-service-root-e2e-firefox-1  |   getElements@http://grafana:3000/__cypress/runner/cypress_runner.js:157945:20
moving-objects-service-root-e2e-firefox-1  |   tryCatcher@http://grafana:3000/__cypress/runner/cypress_runner.js:13012:23
moving-objects-service-root-e2e-firefox-1  |   ../../node_modules/bluebird/js/release/method.js/module.exports/Promise.try@http://grafana:3000/__cypress/runner/cypress_runner.js:10286:29
moving-objects-service-root-e2e-firefox-1  |   resolveElements@http://grafana:3000/__cypress/runner/cypress_runner.js:157995:64
moving-objects-service-root-e2e-firefox-1  |   get@http://grafana:3000/__cypress/runner/cypress_runner.js:158006:14
moving-objects-service-root-e2e-firefox-1  |   now@http://grafana:3000/__cypress/runner/cypress_runner.js:172099:90
moving-objects-service-root-e2e-firefox-1  |   resolveElements@http://grafana:3000/__cypress/runner/cypress_runner.js:158141:19
moving-objects-service-root-e2e-firefox-1  |   tryCatcher@http://grafana:3000/__cypress/runner/cypress_runner.js:13012:23
moving-objects-service-root-e2e-firefox-1  |   ../../node_modules/bluebird/js/release/method.js/module.exports/Promise.try@http://grafana:3000/__cypress/runner/cypress_runner.js:10286:29
moving-objects-service-root-e2e-firefox-1  |   contains@http://grafana:3000/__cypress/runner/cypress_runner.js:158175:62
moving-objects-service-root-e2e-firefox-1  |   ../driver/src/cypress/cy.ts/addCommand/wrapByType/<@http://grafana:3000/__cypress/runner/cypress_runner.js:172022:19
moving-objects-service-root-e2e-firefox-1  |   ../driver/src/cypress/command_queue.ts/runCommand/<@http://grafana:3000/__cypress/runner/cypress_runner.js:170700:15
moving-objects-service-root-e2e-firefox-1  |   tryCatcher@http://grafana:3000/__cypress/runner/cypress_runner.js:13012:23
moving-objects-service-root-e2e-firefox-1  |   ../../node_modules/bluebird/js/release/promise.js/</module.exports/Promise.prototype._settlePromiseFromHandler@http://grafana:3000/__cypress/runner/cypress_runner.js:10947:31
moving-objects-service-root-e2e-firefox-1  |   ../../node_modules/bluebird/js/release/promise.js/</module.exports/Promise.prototype._settlePromise@http://grafana:3000/__cypress/runner/cypress_runner.js:11004:18
moving-objects-service-root-e2e-firefox-1  |   ../../node_modules/bluebird/js/release/promise.js/</module.exports/Promise.prototype._settlePromiseCtx@http://grafana:3000/__cypress/runner/cypress_runner.js:11041:10
moving-objects-service-root-e2e-firefox-1  |   _drainQueueStep@http://grafana:3000/__cypress/runner/cypress_runner.js:7723:12
moving-objects-service-root-e2e-firefox-1  |   _drainQueue@http://grafana:3000/__cypress/runner/cypress_runner.js:7712:24
moving-objects-service-root-e2e-firefox-1  |   ../../node_modules/bluebird/js/release/async.js/</Async.prototype._drainQueues@http://grafana:3000/__cypress/runner/cypress_runner.js:7728:16
moving-objects-service-root-e2e-firefox-1  |   ../../node_modules/bluebird/js/release/async.js/</Async/this.drainQueues@http://grafana:3000/__cypress/runner/cypress_runner.js:7598:14

Desired behavior

I don't want this exception thrown during the unit tests

Test code to reproduce

It happens while running a grafana container and running the e2e tests against it with firefox:

https://gitlab.com/jesperancinha/moving-objects-service-root/

I have an allow-failure flag on for firefox specifically and so it's step won't be marked with an error, but with a warning.

And here is a pipeline result example of this:

https://gitlab.com/jesperancinha/moving-objects-service-root/-/jobs/2823827027

Cypress Version

10.3.0

Other

No response

jesperancinha avatar Aug 07 '22 06:08 jesperancinha

Hi @jesperancinha. Thank you for opening an issue. That is strange that this is happening. are you able to share a light reproduction example to get something similar to your grafana.cy.ts working? Does the test succeed up to this line if you omit the contains?

AtofStryker avatar Aug 09 '22 22:08 AtofStryker

Hi @AtofStryker , thanks for your response.

I've made a separate branch on my repo just to analyse this and isolate the problem: https://gitlab.com/jesperancinha/moving-objects-service-root/-/commits/23175-Grafana-recursion

It seems like this error happens upon performing a click on the control this way:

cy.get('div').contains(/(.*)Java(.*)/).click()

The contains itself could be part of the problem also, but I also see that testing exists on it does not produce the problem. Only click apparently.

jesperancinha avatar Aug 10 '22 20:08 jesperancinha

@jesperancinha thank you for providing that!

I cloned the repo and checked out the branch. I spun up the grafana docker image via docker run -d --name=grafana -p 3000:3000 grafana/grafana and ran npx cypress open against grafana.cy.ts in Firefox 103. My assertion failed. I am guessing I need to add something into the dataset?

AtofStryker avatar Aug 11 '22 19:08 AtofStryker

@AtofStryker , yes you do need to add dashboards to grafana. In my example, grafana already starts up with two pre-configured dashboards. I'm not sure if in your case would it be enough to create just one dashboard to replicate the problem. One of my dashboards contains Java in the name and the other Node. The first one is called Java Virtual Machines and the other Node JS. You probably just need to import the two JSON files located at /docker-files/grafana into Grafana. The Dockerfile is also there and it copies all the necessary files into the container. That way you'll get a more isolated, production-like example.

jesperancinha avatar Aug 12 '22 21:08 jesperancinha

@jesperancinha I gave it a shot and wasn't able to reproduce the issue. What version of firefox are you on? Screen Shot 2022-08-15 at 4 40 31 PM

AtofStryker avatar Aug 15 '22 20:08 AtofStryker

Great @AtofStryker , that is the test! Locally, if I run it, I also have no issue with the open option. With the run option, it runs a bit flaky, with rando timeout errors and this one as well, but it succeeds most of the time. However, in the pipeline, I'm using image cypress/included:10.5.0. I went into the image and checked the firefox version and that is version Mozilla Firefox 99.0.1. Locally I'm running version 103.0.1 (64-bits). You can find my latest pipeline logs here: https://gitlab.com/jesperancinha/moving-objects-service-root/-/jobs/2889544549

The error is still the same:

moving-objects-service-root-e2e-firefox-1  |   0 passing (25s)
moving-objects-service-root-e2e-firefox-1  |   1 failing
moving-objects-service-root-e2e-firefox-1  | 
moving-objects-service-root-e2e-firefox-1  |   1) Grafana Tests
moving-objects-service-root-e2e-firefox-1  |        show grafana:
moving-objects-service-root-e2e-firefox-1  |      InternalError: too much recursion
moving-objects-service-root-e2e-firefox-1  |   cyContainsSelector@http://grafana:3000/__cypress/runner/cypress_runner.js:178635:19
moving-objects-service-root-e2e-firefox-1  |   ../driver/node_modules/jquery/dist/jquery.js/</elementMatcher/Sizzle<@http://grafana:3000/__cypress/runner/cypress_runner.js:102800:22
moving-objects-service-root-e2e-firefox-1  |   superMatcher@http://grafana:3000/__cypress/runner/cypress_runner.js:103021:19
moving-objects-service-root-e2e-firefox-1  |   ../driver/node_modules/jquery/dist/jquery.js/</Sizzle.select@http://grafana:3000/__cypress/runner/cypress_runner.js:103200:44
moving-objects-service-root-e2e-firefox-1  |   Sizzle@http://grafana:3000/__cypress/runner/cypress_runner.js:101368:9
moving-objects-service-root-e2e-firefox-1  |   find@http://grafana:3000/__cypress/runner/cypress_runner.js:103399:11
moving-objects-service-root-e2e-firefox-1  |   ../driver/node_modules/jquery/dist/jquery.js/</jQuery.fn.init@http://grafana:3000/__cypress/runner/cypress_runner.js:103514:40
moving-objects-service-root-e2e-firefox-1  |   query@http://grafana:3000/__cypress/runner/cypress_runner.js:179444:10
moving-objects-service-root-e2e-firefox-1  |   $$@http://grafana:3000/__cypress/runner/cypress_runner.js:158084:65
moving-objects-service-root-e2e-firefox-1  |   getElements@http://grafana:3000/__cypress/runner/cypress_runner.js:153332:20
moving-objects-service-root-e2e-firefox-1  |   tryCatcher@http://grafana:3000/__cypress/runner/cypress_runner.js:11318:23
moving-objects-service-root-e2e-firefox-1  |   ../../node_modules/bluebird/js/release/method.js/module.exports/Promise.try@http://grafana:3000/__cypress/runner/cypress_runner.js:8592:29
moving-objects-service-root-e2e-firefox-1  |   resolveElements@http://grafana:3000/__cypress/runner/cypress_runner.js:153382:64
moving-objects-service-root-e2e-firefox-1  |   get@http://grafana:3000/__cypress/runner/cypress_runner.js:153393:14
moving-objects-service-root-e2e-firefox-1  |   now@http://grafana:3000/__cypress/runner/cypress_runner.js:167424:90
moving-objects-service-root-e2e-firefox-1  |   resolveElements@http://grafana:3000/__cypress/runner/cypress_runner.js:153528:19
moving-objects-service-root-e2e-firefox-1  |   tryCatcher@http://grafana:3000/__cypress/runner/cypress_runner.js:11318:23
moving-objects-service-root-e2e-firefox-1  |   ../../node_modules/bluebird/js/release/method.js/module.exports/Promise.try@http://grafana:3000/__cypress/runner/cypress_runner.js:8592:29

I can reproduce this error everytime I run the pipeline. I was hoping that the new cypress/included:10.5.0 would fix it, but the firefox version doesn't seem to have been updated and I still can reproduce this error in the pipeline everytime the build runs. This is why still have the allow_failure flag on specifically for firefox.

jesperancinha avatar Aug 16 '22 12:08 jesperancinha

@AtofStryker / @rachelruderman , I'm not 100% sure but cypress/included:10.6.0 seems to have fixed the issue as I'm not getting this specific error related to firefox anymore. I still get random timeouts though, but I've explicitly increased them and it seems like all problems have been resolved. I also updated cypress to 10.6.0 locally. On my side, this doesn't seem to be an issue anymore. Feel free to close this issue or to leave it open. I leave it to you to decide because I'm not sure if you want to make this error clearer when it happens, or if you want to find a way to have cypress deal with it, or if you want to leave it as is.

jesperancinha avatar Aug 17 '22 11:08 jesperancinha

Thank you for the update @jesperancinha ! Glad it worked out 😸

rachelruderman avatar Aug 17 '22 19:08 rachelruderman