-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Tests slows down to a crawl and eventually times out/crashes #990
Comments
This is almost the exact same issue I outlined here: #431 (comment) Thanks for the extra work on implementing this with Headless Chrome, this is definitely helpful. :) |
TLDR; run in CLI mode, not GUI mode to prevent OOM crashes on excessively long tests Thank you for putting together a comprehensive example. This is a known issue-ish because it's kind of a bug, but yet also a feature. The reason Cypress is crashing and chrome headless isn't is because of the additional features Cypress provides that no other testing tool does. In this case it's the time travel functionality. Cypress has two basic modes of operation:
There are substantial differences between the two. GUI mode is what you use to iterate and write and run a single test at a time, whilst you build a feature in your application. This is what mode you're working in by default when you open Cypress. CLI mode is when you run test(s) to completion and receive an exit code and summary at the end. GUI mode is optimized for debugging and CLI mode is optimized for running. The reason Cypress is slowing down and crashing is because in GUI mode it takes snapshots for every single command. Under normal circumstances, this isn't a problem. Even tests that have 100 commands rarely ever see this problem. However your test does something pretty unusual - it uses This means that This problem is well known and documented in several places. Here are several issues and proposals that suggest ways to work around this problem:
There are some things Cypress does to try to prevent this from happening. For instance it begins to purge snapshots by default after the 50th test. This number is wayyyy too high, and we're going to be lowering it to something more like 5 in the future. But even if you were to set Likely what we need to do is add another parameter to the configuration that sets a threshold for any given test which exceeds a certain limit of commands. After that number Cypress should begin purging snapshots FIFO style. We should also investigate adding a new As a final note - if you were to run in CLI mode you would not see crashes because Cypress does not snapshot at all in that mode. EDIT: There is one more potential problem I see. Even if you were to run from the CLI and/or turn of snapshotting, because you're using a closure from the I'll keep this issue open since it well documents the "single test" problem vs the "long runs" other people have opened issues about. |
Thank you for that thorough explanation! :) Good catch on the I modified the test but I can't remove all the closures since I need I have set I did rewrite the test not using const BASE_HREF = 'http://tcy-wb040.lenslogistics.int';
const getProductItem = () => {
cy.get('.product-item').then(links => {
/**
* We're using a for-loop to NOT create a closure, otherwise this will bleed memory
*/
for (let i = 0; i < links.length; i = i + 1) {
cy
.visit(`${links[i].href}`)
.get('#productImage-section')
.then($productSection => {
if ($productSection.find('.js-thumbnail-image').length) {
// eslint-disable-next-line no-loop-func
/**
* We do want a closure here, just for these particular thumbnails
*/
cy.get('.js-thumbnail-image').then(thumbnails => {
for (let k = 1; k < thumbnails.length; k = k + 1) {
cy
.wrap(thumbnails[k])
.click()
.get('.product-page__product-header')
.scrollIntoView();
cy.get('#product-image__wrapper').find('.lazyloaded', { timeout: 20000 });
}
});
}
});
}
});
};
describe.only('Do all transformations for LENSES', () => {
before(() => {
const PATH = 'kontaktlinser/linslista';
// cy.visit(`${BASE_HREF}/${PATH}?sort=name&_page=999`).scrollTo('bottom');
cy.visit(`https://www.lensway.se/kontaktlinser/linslista?p_brand=Eyemed%20Technologies`).scrollTo('bottom');
});
it('Should load all product pages and their thumbnails', () => {
getProductItem();
});
}); For some odd reason, the test behaves differently depending on if I run them headlessly or not. Any ideas as to why that is? |
Closing since this was already remarked as wontfix / duplicate. Please comment if you are still experiencing this issue and we can reopen. |
Is this a Feature or Bug?
BUG
Current behavior:
After loading about 50-80 links the test times out or crashes, what-ever comes first.
But it's not our environment that's slow, it's the test itself that's so slow it times out.
I've rewritten the same test using Headless Chrome and it works perfectly so, to me, that indicates a problem with Cypress itself.
The behavior is consistent regardless of browser or computer restart(s).
Desired behavior:
Running a successful test
This test, using puppeteer and headless chrome works and they achieve the same thing:
How to reproduce:
Run the test.
Test code:
Additional Info (images, stack traces, etc)
I'm not getting any stacktraces. The browser window freezes - turns white. Or times out after 60 seconds.
The text was updated successfully, but these errors were encountered: