question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

High CPU Usage Even When Not Automating UI

See original GitHub issue

Current behavior:

When running our test suite we have a number of before hooks that perform some setup making use of cy.request A LOT.

When our tests run we experience super high CPU usage even when not automating the UI (performing the requests). My machine is no slouch but cypress utilises all 4 cores for a http request, this behaviour seems very odd.

image

image

I am only running cypress, chrome and a music player. Even if I shut down all other apps cypress is very greedy.

Desired behavior:

Cypress should not use 100% CPU for performing a HTTP request when the automation is idle.

Test code to reproduce

// the reason we do this chaining is to store the complete output into an object (a string array in this case but that's just for example)
// rather than using some static global
function lotsOfApi(): Cypress.Chainable<string[]> {
  let chain: Cypress.Chainable<null | Cypress.Response> = cy.wrap(null);
  const testData: string[] = [];
  for (let i = 0; i < 1000; i++) {
    chain = chain.then(() => {
      return cy.request('https://dummyapi.io/data/api/user').then((response) => {
        // store some values from response
        testData.push(response.statusText);
      });
    });
  }
  return chain.then(() => testData);
}

describe('lots of api tests', () => {

  let testData: string[] | null = null;

  before(() => lotsOfApi().then((d) => (testData = d)));

  it('should have data', () => assert.isArray(testData));

});

Versions

Cypress: v4.12.1 OS: Windows 10 Browser: Electron (or chrome)

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

2reactions
shwarcucommented, Sep 7, 2020

Performance issues in Cypress is something quite common. In my case on Macbook Pro 16 with 32GB of ram, after running a suite of tests I can barely select commands in the preview and see snapshots of the page from that point of time. It takes a lot of time for Cypress to update view of test runner. It’s very very slow, sometimes unusable.

I have run your code, result was identical. Cypress processes entirely occupied CPU and my mac started to heat up. I will try to run this snipped at home with Ryzen 2700X and see if Cypress will also consume entire cpu with this task.

0reactions
rajutandukarcommented, Nov 19, 2022

i am also having same issue . i use macOs 2GHz core intel core i5, 16GB. Cypress get hung and have to force quit even nothing were ran.

Read more comments on GitHub >

github_iconTop Results From Across the Web

UIFlowservice CPU usage - Power Platform Community
I'm not seeing the CPU drain you are from UIFlowService. Mine is usually at around 0.1% even when I'm editing a Desktop flow....
Read more >
High CPU Utilisation when Bot is trying to run the Automation ...
We tried to diagnose the issue by clearing cache & cookies and restarting the VDI. But the workaround was unsuccessful.
Read more >
How To FIX High CPU Usage on Windows 10 - YouTube
How to Fix High RAM/Memory Usage on Windows 10: https://www.youtube.com/watch?v=osKnDbHibig&t=0s How to Fix High Disk Usage on Windows 10: ...
Read more >
High CPU usage even when idle - MuseScore
I expect a program such as Musescore to use CPU only when it receives some UI event, do some computation or perform some...
Read more >
UDM-Pro CPU Usage 97%+ Unifi is having Trouble with this ...
UPDATE: I have been able to reproduce the CPU Spike and Hold behavior 4 times in a row now. No other changes. Just...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found