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

Possible memory leak in v5.3.2 #203

Closed
joydeep100 opened this issue Aug 17, 2023 · 20 comments
Closed

Possible memory leak in v5.3.2 #203

joydeep100 opened this issue Aug 17, 2023 · 20 comments
Labels
bug Something isn't working

Comments

@joydeep100
Copy link

We started observing that cypress is running out of memory and starts to crash as OOM error after we upgraded from 5.1.1 to 5.3.2

cypress-io/cypress#27574

@archfz
Copy link
Owner

archfz commented Aug 21, 2023

I have a feeling that this might be caused by the fix for #184

Could you help narrow down the issue? Are you using any asserts? Check if issue is reproducing in 5.2.0 already.

Besides this it would be helpful if you can provide a minimal reproducible example.

@joydeep100
Copy link
Author

joydeep100 commented Aug 23, 2023

@archfz

Issue does not replicate in 5.2.0

Below is the console logs when testing with 5.1.1 / 5.2.0

vboxuser@ubuntu:~/work2/iot_rwt$ npx cypress run --config video=false --browser electron --spec cypress/e2e/test/CCTests/Example_Recipies/Example_Recipies.spec.js --env env=demoenv,login=demo,testdatafile=Example_Recipies,dataset=1

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

  (Run Starting)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:        12.4.0                                                                         │
  │ Browser:        Electron 106 (headless)                                                        │
  │ Node Version:   v16.13.2 (/home/vboxuser/.nvm/versions/node/v16.13.2/bin/node)                 │
  │ Specs:          1 found (Example_Recipies.spec.js)                                             │
  │ Searched:       cypress/e2e/test/CCTests/Example_Recipies/Example_Recipies.spec.js             │
  │ Experiments:    experimentalMemoryManagement=true,experimentalModifyObstructiveThirdPartyCode… │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


────────────────────────────────────────────────────────────────────────────────────────────────────
                                                                                                    
  Running:  Example_Recipies.spec.js                                                        (1 of 1)


  Example recipies of cypress tests
      cy:command ✔  session	ccSession
      cy:command ✔  sessions_manager	
      cy:command ✔  session	
      cy:command ✔  wrap	https://mytestingapp.com
      cy:command ✔  visit	https://mytestingapp.com/provision/jsp/login.jsp?APP_MODE=AWT_TESTING
      cy:command ✔  wrap	Object{4}
      cy:command ✔  get	[data-awt='userName']
      cy:command ✔  clear	
      cy:command ✔  get	[data-awt='password']
      cy:command ✔  clear	
      cy:command ✔  get	[data-awt='logonSubmit']
      cy:command ✔  click	
      cy:command ✔  form sub	--submitting form--
      cy:command ✔  page load	--page loaded--
      cy:command ✔  new url	https://mytestingapp.com/provision/ui/m2mhome/m2mhome.html
        cons:log ✱  create date prototypes
        cons:log ✱  Creating demoapp Object
        cons:log ✱  demoapp Loaded
        cons:log ✱  is demo image %o,
                    true
        cons:log ✱  commmon.resources.jsp EXT ready has been loaded..
          cy:xhr ➟  GET https://mytestingapp.com/provision/api/v1/users/searchUserProfile?_dc=1692782687868&page=1&limit=1&sort=login&dir=ASC&search=%5B%7B%22property%22%3A%22userId%22%2C%22type%22%3A%22LONG_EQUALS%22%2C%22value%22%3A69996%2C%22id%22%3A%22userId%22%7D%5D (1.639 s)
                    Status: 200
          cy:xhr ➟  GET https://mytestingapp.com/provision/api/v1/users/searchUserProfile?_dc=1692782687874&page=1&limit=50&sort=login&dir=ASC&search=%5B%7B%22property%22%3A%22userId%22%2C%22type%22%3A%22LONG_EQUALS%22%2C%22value%22%3A69996%2C%22id%22%3A%22userId%22%7D%5D (1.627 s)
                    Status: 200
        cons:log ✱  calling the pages launch method
      cy:command ✔  get	body
      cy:command ✔  get	.jw-navtiles
      cy:command ✔  assert	expected **<div.jw-navtiles>** to be **visible**
      cy:command ✔  wrap	https://mytestingapp.com
      cy:command ✔  wrap	https://mytestingapp.com
      cy:command ✔  wrap	https://mytestingapp.com
      cy:command ✔  wrap	https://mytestingapp.com
      cy:command ✔  wrap	/provision/ui/terminals/sims/sims.html
      cy:command ✔  get	@base_domain
      cy:command ✔  get	@page_url
      cy:command ✔  visit	https://mytestingapp.com/provision/ui/terminals/sims/sims.html
        cy:fetch ➟  GET https://cdn.demoapp.com/users/5fa1542360724d11a1b3b03e128c3c98/staging/data_2d580b37a7f94ced84bb9caa756b0250.br.json (5.044 s)
                    Status: 200
          cy:xhr ➟  POST https://ec.demoapp.com/event/postEvent
        cons:log ✱  create date prototypes
        cons:log ✱  Creating demoapp Object
        cons:log ✱  demoapp Loaded
        cons:log ✱  is demo image %o,
                    true
        cons:log ✱  commmon.resources.jsp EXT ready has been loaded..
        cons:log ✱  calling the pages launch method
          cy:xhr ➟  GET https://mytestingapp.com/provision/api/v1/users/searchUserProfile?_dc=1692782693261&page=1&limit=50&sort=login&dir=ASC&search=%5B%7B%22property%22%3A%22userId%22%2C%22type%22%3A%22LONG_EQUALS%22%2C%22value%22%3A69996%2C%22id%22%3A%22userId%22%7D%5D
       cons:info ✱  showing %o,
                    [unprocessable=[object Object]]
          cy:xhr ➟  GET https://mytestingapp.com/provision/api/v1/customGridConfig?_dc=1692782693722&pagePath=%2Fterminals%2Fsims%2Fsims.html&gridId=simsGrid (1.201 s)
                    Status: 200
          cy:xhr ➟  POST https://ec.demoapp.com/event/postEvent (1.178 s)
                    Status: 200
          cy:xhr ➟  GET https://mytestingapp.com/provision/api/v1/sims?_dc=1692782693873&page=1&limit=50&sort=dateAdded&dir=DESC
          cy:xhr ➟  POST https://ec.demoapp.com/event/postEvent (730 ms)
                    Status: 200
          cy:log ✱  Runs after each test


    ✓ CC Navigation examples (17502ms)


  1 passing (31s)

[mochawesome] Report JSON saved to /home/vboxuser/work2/iot_rwt/cypress/reports/mocha/mochawesome_003.json


  (Results)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Tests:        1                                                                                │
  │ Passing:      1                                                                                │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        false                                                                            │
  │ Duration:     30 seconds                                                                       │
  │ Spec Ran:     Example_Recipies.spec.js                                                         │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


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

  (Run Finished)


       Spec                                              Tests  Passing  Failing  Pending  Skipped  
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ ✔  Example_Recipies.spec.js                 00:30        1        1        -        -        - │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
    ✔  All specs passed!                        00:30        1        1        -        -        -  

vboxuser@ubuntu:~/work2/iot_rwt$ 


@kalcefer
Copy link

I also get this kind of error. On the plugin version 5.3.3

Always appears in input type input fields

example

сy.get("input").type("test")
cy.get("input").clear()

@archfz
Copy link
Owner

archfz commented Aug 31, 2023

I am still facing issues reproducing this. The tests in this repository also use input typing.

Best would be if you could create a repository in which you reproduce it and send it here.

In 5.3 the safe json stringify was introduced. This maybe can cause the issue, but this is only used for expects.actual and for console logs. I don't see in your Example_Recipies.spec.js any unexpected formats that could cause such issues though. But you could try to add a config on support side collectTypes that excludes all cons:* types to confirm that is not the issue.

@joydeep100
Copy link
Author

@archfz Tried with the following code in the support file

const options = {
  collectTypes: ["cons:*"],
};
require('cypress-terminal-report/src/installLogsCollector')(options);

getting the following error

The following error originated from your test code, not from Cypress.

  > cypress-terminal-report: Invalid plugin install options:

=> .collectTypes/0: No enum match for: "cons:*"

@archfz
Copy link
Owner

archfz commented Sep 13, 2023

Check the doc, you need exact values there. Also I was proposing to include all but the ones that start with cons.

@archfz
Copy link
Owner

archfz commented Sep 13, 2023

After reviewing the issue again I have noticed that you have a particular console info log:

       cons:info ✱  showing %o,
                    [unprocessable=[object Object]]

I believe this could be where the issues is reproducing. Maybe that object is too big somehow, or the library that is handling stringification is not handling too big objects properly.

I have decided to try out another library. https://www.npmjs.com/package/stringify-object
Released experimental fix in 5.3.5. @joydeep100 @kalcefer Can you guys try the version to see if it fixes the issue?

@archfz archfz added bug Something isn't working and removed clarification labels Sep 13, 2023
@joydeep100
Copy link
Author

@archfz Tested with version 5.3.5

➜ iot_rwt git:(develop) ✗ npm list | grep term
+-- cypress-terminal-report@5.3.5

Got the same issue.

We detected that the Chromium Renderer process just crashed.

This is the equivalent to seeing the 'sad face' when Chrome dies.

This can happen for a number of different reasons:

- You wrote an endless loop and you must fix your own code
- You are running Docker (there is an easy fix for this: see link below)
- You are running lots of tests on a memory intense application.
    - Try enabling experimentalMemoryManagement in your config file.
    - Try lowering numTestsKeptInMemory in your config file.
- You are running in a memory starved VM environment.
    - Try enabling experimentalMemoryManagement in your config file.
    - Try lowering numTestsKeptInMemory in your config file.
- There are problems with your GPU / GPU drivers
- There are browser bugs in Chromium

You can learn more including how to fix Docker here:

https://on.cypress.io/renderer-process-crashed
Renderer process crashed - see https://www.electronjs.org/docs/tutorial/application-debugging for potential debugging information.

@joydeep100
Copy link
Author

@archfz Isolated the issue to collectTypes: ['cons:info']

when i removed just the info part it worked.

Tested on 5.3.5 with the below options

const options = {collectTypes: ['cons:log', 'cons:warn', 'cons:error', 'cy:log', 'cy:xhr', 'cy:request', 'cy:intercept', 'cy:command'],}

It worked!

Sharing our configs in condig.cypress.js as well.

    setupNodeEvents(on, config) {
      require('cypress-terminal-report/src/installLogsPrinter')(on,{
        printLogsToConsole: "always",
      });
      return require('./cypress/plugins/index.js')(on, config)
    },
    ```

@archfz
Copy link
Owner

archfz commented Sep 14, 2023

@joydeep100 Could you describe the object that is console info logged? Somehow that is casuing the issue but I am struggling to understand how.

@archfz
Copy link
Owner

archfz commented Sep 14, 2023

Just check in the browsers console how that object looks like. Can you say it's big? Does it have circular references? Or any other particular things?

Maybe try to json stringify it and send it here or just send a screenshot of the log in the browser console (inspector).

@joydeep100
Copy link
Author

joydeep100 commented Sep 14, 2023

Sure..

image

Expanding the showing > j

image

image

@archfz
Copy link
Owner

archfz commented Sep 14, 2023

Yeah, that object is for sure huge, as it has even the dom body in it. Now I wonder what we can do to avoid issue with this.

@archfz
Copy link
Owner

archfz commented Sep 14, 2023

Could you run the following gist on your object? https://gist.github.com/rajinwonderland/36887887b8a8f12063f1d672e318e12e

And tell me how big is the memory size of it?

@joydeep100
Copy link
Author

Seems like a pretty huge object!!

image

@archfz
Copy link
Owner

archfz commented Sep 14, 2023

I am struggling to see a solution for this. Previously we used JSON.stringify, which was working for your case because it breaks with cycles error. But now we support decycling and printing such complex objects as well, but this in turn allowes not serializing your very large object which exhausts the memory.

We either revert back and break support or we maybe need a library that supports max depth setting.

@archfz
Copy link
Owner

archfz commented Sep 14, 2023

Could you maybe try to serialize with this? https://github.com/Canop/JSON.prune

@joydeep100
Copy link
Author

Yes JSON.prune() works. Attaching the output.

json.prune.txt

archfz added a commit that referenced this issue Sep 15, 2023
@archfz
Copy link
Owner

archfz commented Sep 15, 2023

Check if 3.5.6 resolves the issue.

@joydeep100
Copy link
Author

@archfz You mean 5.3.6 right. Yeah it works.

Now the object is printed something like this

       cons:info ✱  showing %o,
                    {
                      "searchToolbar": {
                        "xtype": "jw-searchbar",
                        "containerId": "simsGrid",
                        "oneBoxSearchColumns": [
                          "iccid",
                          "modemId",
                          "endConsumerIdentity",
                          "customer",
                          "imsi",
                          "acctManagementSystemId",
                          "msisdn",
                          "notes",
                          "imsi1"
                        ],
                        "searchModel": {
                          "searchConfigsByName": {
                            "oneBox": [
                              {
                                "field": {
                                  "xtype": "jw-searchfield",
                                  "name": "oneBox",
                                  "width": 300,
                                  "field": "textfield",
                                  "initialConfig": {
                                    "xtype": "jw-searchfield",
                                    "name": "oneBox",
                                    "width": 350,
                                    "field": "textfield"
                                  },
                                  "events": {
                                    "blur": {
                              ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants