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 10 component test crash after 100~ tests #22208

Closed
gvocale opened this issue Jun 8, 2022 · 29 comments
Closed

Cypress 10 component test crash after 100~ tests #22208

gvocale opened this issue Jun 8, 2022 · 29 comments
Assignees
Labels
CT Issue related to component testing existing workaround stage: awaiting response Potential fix was proposed; awaiting response type: bug v10.0.2 🐛 Issue present since 10.0.2

Comments

@gvocale
Copy link

gvocale commented Jun 8, 2022

Current behavior

Both on CI and on localhost, after running a hundred component tests (i.e. 138 of 227) via cypress run --component, Cypress 10 would fail with the following error:

ERR_FAILED (-2) loading 'http://localhost:8080/__/#/specs/runner?file=src/dct/components/HoverableItem/Collection/test.tsx'
Error: ERR_FAILED (-2) loading 'http://localhost:8080/__/#/specs/runner?file=src/dct/components/HoverableItem/Collection/test.tsx'
    at rejectAndCleanup (node:electron/js2c/browser_init:161:7647)
    at EventEmitter.stopLoadingListener (node:electron/js2c/browser_init:161:8022)
    at EventEmitter.emit (node:events:390:28)
    at EventEmitter.emit (node:domain:475:12)


────────────────────────────────────────────────────────────────────────────────────────────────────

  Running:  test.tsx                                                                    (139 of 227)
Unhandled rejection Error: ERR_FAILED (-2) loading 'about:blank'
    at rejectAndCleanup (node:electron/js2c/browser_init:161:7647)
    at EventEmitter.stopLoadingListener (node:electron/js2c/browser_init:161:8022)
    at EventEmitter.emit (node:events:390:28)
    at EventEmitter.emit (node:domain:475:12)

If I run the failing test via cypress open it passes correctly.

If I comment out the component test that provoked the error, another one will trip with the same error, usually around the same ~120 of ... 227 number.

Desired behavior

All component tests should run correctly

Test code to reproduce

Doesn't matter...event the following fails:

import { Disabled } from ".";

describe("Disabled", () => {
  it("Should render", () => {
    cy.mountWithTheme(<Disabled />);
    cy.contains("How would you like to pay?");
  });
});

Cypress Version

10.0.3

Other

No response

@lmiller1990 lmiller1990 added component testing v10.0.2 🐛 Issue present since 10.0.2 labels Jun 9, 2022
@lmiller1990
Copy link
Contributor

Hey, thanks for the feedback. Interesting... I wondered if this is CI-related memory issue, but you get the same thing both locally and on CI? Or, perhaps, a memory leak somewhere and the browser has a hard limit.

I'm guessing this is not an open source repo - are you able to share some info, maybe package.json and cypress.config? Are you using webpack or vite? Also, what browser are you running? Would you be able to try another to see if it's consistent? Also to clarify, when you say test you mean the number of files? 100 tests => 100 files?

We have several projects but none running 100+ specs in a single shot - they run in parallel in separate containers, which is perhaps why we didn't hit this.

If you could provide some more info, that'd be great - in the meantime I will try to make a project on my machine that has a bunch of specs and see what happens.

@lmiller1990 lmiller1990 added blocking CT Issue related to component testing labels Jun 9, 2022
@cypress-bot cypress-bot bot added the stage: awaiting response Potential fix was proposed; awaiting response label Jun 9, 2022
@JoaoTMDias
Copy link

JoaoTMDias commented Jun 12, 2022

Same thing is happening to me.
The tests run fine on my machine, but once I run them on my company's CI/CD, it fails with the same error.

Here the cypress.config.js:

const { defineConfig } = require("cypress");
const webpackPreprocessor = require('@cypress/webpack-preprocessor')
const webpackConfig = require("./webpack.dev");

export default defineConfig({
    env: {
      codeCoverage: {
        exclude: 'cypress/**/*.*'
      }
    },
    component: {
        retries: {
            runMode: 2,
        },
        video: false,
        fixturesFolder: false,
        setupNodeEvents(on, config) {
            require("@cypress/code-coverage/task")(on, config);

            const options = {
                // send in the options from your webpack.config.js, so it works the same
                // as your app's code
                webpackOptions: require("./webpack.prod"),
                watchOptions: {},
            };

            on("file:preprocessor", webpackPreprocessor(options));

            return config;
        },
        devServer: {
            framework: "react",
            bundler: "webpack",
            webpackConfig,
        },
        viewportWidth: 800,
        viewportHeight: 800,
        supportFile: "cypress/support/index.ts",
    },
});

And the package.json:

{
    ...,
    "engine": {
        "node": "^14.19.0",
        "npm": "^6.14.16"
    },
    "main": "dist/index.js",
    "typings": "dist/index.d.ts",
    "files": [
        "dist"
    ],
   ...
    "scripts": {
        "start": "start-storybook -p 8000",
        "coverage:clean": "merge-coverage clean || true",
        "coverage:merge": "merge-coverage combine || node ./scripts/merge-coverage.js",
        "pretest": "npm run coverage:clean",
        "test:jest": "jest --coverage --env=jest-environment-jsdom-sixteen",
        "test:jest-watch": "jest --watch --env=jest-environment-jsdom-sixteen",
        "test:components-open": "NODE_ENV=cypress cypress open --component",
        "test:components-run": "NODE_ENV=cypress cypress run --component",
        "test": "npm run test:jest && npm run test:components-run && npm run coverage:merge",
        "build:types": "tsc --project ./tsconfig.json",
        "build": "npm run clean && npm run build:types && npm run build:scss && npm run build:webpack",
        "build:scss": "cpx \"src/assets/styles/**/*!(*.stories.{js,mdx})\" dist",
        "build:webpack": "webpack --mode production --config webpack.prod.js",
        "clean": "rm -rf dist styleguide",
        "lint": "npm run lint:js && npm run lint:css",
        "lint:js": "eslint \"src/components/**/*.{js,jsx,ts,tsx}\" --fix",
        "lint:css": "stylelint \"src/components/**/*.scss\" --fix",
        "deploy:major": "npm version major && git push --follow-tags",
        "deploy:minor": "npm version minor && git push --follow-tags",
        "deploy:patch": "npm version patch && git push --follow-tags",
        "deploy:candidate": "npm version prerelease --preid=rc && git push --follow-tags",
        "storybook:build": "NODE_OPTIONS=--max_old_space_size=4096 build-storybook -o ./styleguide",
        "storybook:watch": "build-storybook -w -o ./styleguide",
        "analyze": "repo-analyzer",
        "reinstall": "rm -rf node_modules && npm run clean && npm install",
        "format": "npm run format:js && npm run format:css",
        "format:js": "prettier --write \"src/**/*.{js,jsx,ts,tsx}\"",
        "format:css": "prettier --write \"src/**/*.scss\"",
        "format:check": "prettier --check \"src/**/*.{js,jsx,ts,tsx}\" \"src/**/*.scss\""
    },
...
    "peerDependencies": {
        "react": ">= 16"
    },
    "devDependencies": {
        "@babel/cli": "7.14.5",
        "@babel/core": "7.14.6",
        "@babel/plugin-proposal-class-properties": "7.14.5",
        "@babel/plugin-proposal-object-rest-spread": "7.14.7",
        "@babel/plugin-proposal-private-methods": "7.14.5",
        "@babel/plugin-transform-modules-commonjs": "7.14.5",
        "@babel/plugin-transform-runtime": "7.14.5",
        "@babel/plugin-transform-typescript": "7.14.6",
        "@babel/preset-env": "7.14.7",
        "@babel/preset-react": "7.14.5",
        "@babel/preset-typescript": "7.14.5",
        "@babel/runtime": "7.14.6",
        "@cypress/code-coverage": "3.10.0",
        "@cypress/react": "5.12.5",
        "@cypress/webpack-dev-server": "1.8.4",
        "@cypress/webpack-preprocessor": "5.12.0",
        "@feedzai/eslint-config-feedzai": "4.0.1",
        "@feedzai/eslint-config-feedzai-react": "4.1.0",
        "@feedzai/merge-coverage": "1.0.1",
        "@feedzai/repo-analyzer": "0.1.46",
        "@sambego/storybook-state": "2.0.1",
        "@shopify/jest-dom-mocks": "2.11.3",
        "@storybook/addon-a11y": "6.5.4",
        "@storybook/addon-actions": "6.5.4",
        "@storybook/addon-controls": "6.5.4",
        "@storybook/addon-essentials": "6.5.4",
        "@storybook/addon-knobs": "6.4.0",
        "@storybook/addon-links": "6.5.4",
        "@storybook/addons": "6.5.4",
        "@storybook/builder-webpack5": "6.5.4",
        "@storybook/client-api": "6.5.4",
        "@storybook/manager-webpack5": "6.5.4",
        "@storybook/react": "6.5.4",
        "@storybook/source-loader": "6.5.4",
        "@testing-library/cypress": "8.0.2",
        "@testing-library/jest-dom": "5.13.0",
        "@testing-library/react": "11.2.7",
        "@testing-library/react-hooks": "7.0.1",
        "@testing-library/user-event": "12.8.3",
        "@types/classnames": "2.3.0",
        "@types/enzyme": "3.10.9",
        "@types/html-webpack-plugin": "3.2.6",
        "@types/jest": "26.0.24",
        "@types/jest-axe": "3.5.2",
        "@types/lodash": "4.14.171",
        "@types/node": "16.3.3",
        "@types/react": "17.0.14",
        "@types/react-dom": "17.0.9",
        "@types/react-select": "5.0.1",
        "@types/webpack": "5.28.0",
        "@typescript-eslint/eslint-plugin": "4.25.0",
        "@typescript-eslint/parser": "4.25.0",
        "autoprefixer": "10.3.1",
        "axe-core": "4.4.1",
        "babel-eslint": "10.0.2",
        "babel-jest": "26.6.3",
        "babel-loader": "8.2.2",
        "babel-plugin-import": "1.13.3",
        "babel-plugin-istanbul": "6.1.1",
        "babel-plugin-lodash": "3.3.4",
        "babel-plugin-module-resolver": "4.1.0",
        "babel-plugin-react-docgen": "4.2.1",
        "chalk": "4.1.0",
        "copy-webpack-plugin": "9.0.1",
        "core-js": "3.15.2",
        "cpx": "1.5.0",
        "css-loader": "5.2.6",
        "cypress": "10.1.0",
        "cypress-real-events": "1.7.0",
        "duplicate-package-checker-webpack-plugin": "3.0.0",
        "enzyme": "3.11.0",
        "enzyme-adapter-react-16": "1.15.6",
        "enzyme-to-json": "3.6.2",
        "eslint": "6.1.0",
        "eslint-config-prettier": "8.3.0",
        "eslint-import-resolver-typescript": "2.4.0",
        "eslint-plugin-cypress": "2.12.1",
        "eslint-plugin-import": "2.23.4",
        "eslint-plugin-jest": "24.4.0",
        "eslint-plugin-jsx-a11y": "6.4.1",
        "eslint-plugin-prettier": "3.4.0",
        "eslint-plugin-react": "7.14.2",
        "eslint-plugin-react-hooks": "4.2.0",
        "feedzai-config": "1.0.22",
        "file-loader": "1.1.11",
        "github-markdown-css": "2.10.0",
        "html-webpack-plugin": "5.3.2",
        "identity-obj-proxy": "3.0.0",
        "internal-analyzer-config": "1.0.10",
        "istanbul-instrumenter-loader": "3.0.1",
        "jest": "26.6.3",
        "jest-axe": "5.0.1",
        "jest-environment-jsdom-sixteen": "2.0.0",
        "json-loader": "0.5.7",
        "lint-staged": "10.5.4",
        "lodash-webpack-plugin": "0.11.6",
        "mini-css-extract-plugin": "1.6.0",
        "null-loader": "0.1.1",
        "path": "0.12.7",
        "polished": "4.1.3",
        "postcss": "8.3.6",
        "postcss-loader": "6.1.1",
        "postcss-preset-env": "6.7.0",
        "prettier": "2.3.1",
        "process": "0.11.10",
        "raf": "3.4.1",
        "react": "16.14.0",
        "react-dom": "16.14.0",
        "react-router-dom": "5.2.0",
        "react-select-event": "5.3.0",
        "react-syntax-highlighter": "15.5.0",
        "react-test-renderer": "17.0.2",
        "sass": "1.35.2",
        "sass-loader": "10.1.1",
        "string.prototype.replaceall": "1.0.5",
        "style-loader": "2.0.0",
        "stylelint": "13.13.1",
        "stylelint-config-prettier": "8.0.2",
        "stylelint-config-standard": "22.0.0",
        "stylelint-prettier": "1.2.0",
        "stylelint-scss": "3.20.1",
        "tsconfig-paths-webpack-plugin": "3.5.1",
        "typescript": "4.3.5",
        "url-loader": "1.0.1",
        "webpack": "5.46.0",
        "webpack-ant-icon-loader": "1.0.8",
        "webpack-bundle-analyzer": "4.4.2",
        "webpack-cli": "4.7.2",
        "webpack-dev-server": "4.7.4",
        "webpack-merge": "5.8.0"
    },
    "dependencies": {
        "@feedzai/react-a11y-tools": "1.1.0",
        "@feedzai/react-selectv1": "1.0.0",
        "@feedzai/ui-primitives": "4.1.0",
        "@visx/scale": "2.2.2",
        "antd": "4.8.2",
        "classnames": "2.3.1",
        "fdz-matomo-web": "1.0.2",
        "focus-trap-react": "8.7.0",
        "leaflet": "1.7.1",
        "lodash": "4.17.21",
        "moment": "2.29.3",
        "moment-timezone": "0.5.33",
        "prop-types": "15.7.2",
        "rc-tooltip": "5.1.1",
        "react-command-palette": "0.12.0-0",
        "react-datetime": "2.16.2",
        "react-leaflet": "2.7.0",
        "react-modal": "3.14.3",
        "react-notification": "6.8.5",
        "react-select": "2.1.2",
        "react-sortable-hoc": "1.7.1",
        "react-transition-group": "4.4.2",
        "react-use": "15.3.4",
        "react-virtualized": "9.22.3",
        "uuid": "3.3.2"
    },
    "husky": {
        "hooks": {
            "pre-commit": "lint-staged"
        }
    },
    "lint-staged": {
        "*.js": [
            "npm run lint:js"
        ],
        "*.scss": [
            "npm run lint:css"
        ]
    },
    "nyc": {
        "all": true,
        "report-dir": "coverage-reports/cypress",
        "reporter": [
            "lcov",
            "json"
        ],
        "check-coverage": true,
        "watermarks": {
            "statements": 80,
            "branches": 70,
            "functions": 80,
            "lines": 80
        },
        "include": [
            "src/**/*"
        ]
    }
}

I omitted a couple of details from the file that were confidential ,but I think this has the gist of it.

@JoaoTMDias
Copy link

And here is the screenshot:
image

@JoaoTMDias
Copy link

Ok, I think I'm on to something. I ran the tests with chrome and not electron and they passed, three times in a row. So, perhaps it might be something related with electron? 🤷

@cypress-bot cypress-bot bot added stage: investigating Someone from Cypress is looking into this and removed stage: awaiting response Potential fix was proposed; awaiting response labels Jun 13, 2022
@lmiller1990
Copy link
Contributor

lmiller1990 commented Jun 14, 2022

Interesting - that's really useful info, we are always running on Chrome in CI as well for our component tests. This is useful info for @AtofStryker who's looking into this, but running in Chrome seems like a good work around for now, especially if you are developing a web app, since that's what most people will be using to consume your components.

Electrons apps are definitely a thing though, so it'd be nice to isolate what exactly the difference in between electron vs chrome. They should be quite similar, all things considered.

Next step for debugging would probably be seeing what happens in Chromium.

@AtofStryker
Copy link
Contributor

Hey @gvocale. Sorry for the delay in getting to this issue. I am having some trouble reproducing the error. I created a reproduction repository here similar to @JoaoTMDias 's configuration (I took a guess at the webpack config) and was unable to reproduce with yarn cypress run --component. Would you be able to take a look at the reproduction and see if you can recreate the issue?

@gvocale
Copy link
Author

gvocale commented Jun 21, 2022

@AtofStryker the reproduction works correctly without errors on my localhost.

I updated packages to latest and re-run cypress run --component on my localhost, still running in the same issues, this time it crashed at 190 of 230 tests.

When running cypress run --component, does it run in Chrome, Electron, or else?

ERR_FAILED (-2) loading 'http://localhost:8080/__/#/specs/runner?file=src/dct/components/Checkout/Payment/Query/test.tsx'
Error: ERR_FAILED (-2) loading 'http://localhost:8080/__/#/specs/runner?file=src/dct/components/Checkout/Payment/Query/test.tsx'
    at rejectAndCleanup (node:electron/js2c/browser_init:161:7647)
    at EventEmitter.stopLoadingListener (node:electron/js2c/browser_init:161:8022)
    at EventEmitter.emit (node:events:390:28)
    at EventEmitter.emit (node:domain:475:12)

Unhandled rejection Error: ERR_FAILED (-2) loading 'about:blank'
    at rejectAndCleanup (node:electron/js2c/browser_init:161:7647)
    at EventEmitter.stopLoadingListener (node:electron/js2c/browser_init:161:8022)
    at EventEmitter.emit (node:events:390:28)
    at EventEmitter.emit (node:domain:475:12)

@AtofStryker
Copy link
Contributor

I updated packages to latest and re-run cypress run --component on my localhost, still running in the same issues, this time it crashed at 190 of 230 tests.

@gvocale when you say "updated packages to latest" do you mean in the reproduction repository or the original posted code?

When running cypress run --component, does it run in Chrome, Electron, or else?

By default it should run in electron. If you want to run it in chrome, for instance, you could run cypress run --component --browser chrome.

@mjhenkes mjhenkes assigned lmiller1990 and unassigned AtofStryker Jun 21, 2022
@cypress-bot cypress-bot bot added stage: awaiting response Potential fix was proposed; awaiting response and removed stage: investigating Someone from Cypress is looking into this labels Jun 21, 2022
@gvocale
Copy link
Author

gvocale commented Jun 22, 2022

@AtofStryker I have just tried running cypress run --component --browser electron with cypress 10.2.0 and the problem persists. I have updated packages to latest in my original local repo, not the reproduction repository."

ERR_FAILED (-2) loading 'http://localhost:8080/__/#/specs/runner?file=src/dct/components/Checkout/Payment/Query/test.tsx'
Error: ERR_FAILED (-2) loading 'http://localhost:8080/__/#/specs/runner?file=src/dct/components/Checkout/Payment/Query/test.tsx'
    at rejectAndCleanup (node:electron/js2c/browser_init:161:7647)
    at EventEmitter.stopLoadingListener (node:electron/js2c/browser_init:161:8022)
    at EventEmitter.emit (node:events:390:28)
    at EventEmitter.emit (node:domain:475:12)


────────────────────────────────────────────────────────────────────────────────────────────────────

  Running:  test.tsx                                                                    (190 of 230)
Unhandled rejection Error: ERR_FAILED (-2) loading 'about:blank'
    at rejectAndCleanup (node:electron/js2c/browser_init:161:7647)
    at EventEmitter.stopLoadingListener (node:electron/js2c/browser_init:161:8022)
    at EventEmitter.emit (node:events:390:28)
    at EventEmitter.emit (node:domain:475:12)

@cypress-bot cypress-bot bot added stage: investigating Someone from Cypress is looking into this and removed stage: awaiting response Potential fix was proposed; awaiting response labels Jun 22, 2022
@lmiller1990
Copy link
Contributor

lmiller1990 commented Jun 23, 2022

@gvocale can you see if the same thing happens in chrome (on CI and locally?) cypress run --component --browser chrome. You might need to install chrome, depending on your CI setup, or you can use one of our docker images, some of which have chrome. Those are here: https://github.com/cypress-io/cypress-docker-images

When running cypress run --component, does it run in Chrome, Electron, or else?

There are some other issues that look like they'll be fixed when we update to Electron 19 - this might be one of them. If Chrome has the same problem, we will know it's not related to Electron, and can dig deeper.

@cypress-bot cypress-bot bot added stage: open and removed stage: investigating Someone from Cypress is looking into this labels Jun 23, 2022
@gvocale
Copy link
Author

gvocale commented Jun 23, 2022

@lmiller1990 running cypress run --component --browser chrome fixes it indeed! All tests run correctly!

@lmiller1990
Copy link
Contributor

Good to know it's an electron issue. I wouldn't say chrome fixes it - it just avoids it, haha.

We have some work coming soon to update the electron version we use, maybe that will fix this issue. Until then, I'm going to hold off on looking into this. If the electron 19.x bump doesn't fix it, I'll take another look.

@gvocale
Copy link
Author

gvocale commented Jun 25, 2022

Never mind... seems to fail again on CI....:

ERR_FAILED (-2) loading 'http://localhost:8080/__/#/specs/runner?file=src/dct/components/Checkout/Payment/Query/Query.cy.tsx'
Error: ERR_FAILED (-2) loading 'http://localhost:8080/__/#/specs/runner?file=src/dct/components/Checkout/Payment/Query/Query.cy.tsx'
    at rejectAndCleanup (node:electron/js2c/browser_init:161:7647)
    at EventEmitter.stopLoadingListener (node:electron/js2c/browser_init:161:8022)
    at EventEmitter.emit (node:events:390:28)
    at EventEmitter.emit (node:domain:475:12)
Unhandled rejection Error: ERR_FAILED (-2) loading 'about:blank'
    at rejectAndCleanup (node:electron/js2c/browser_init:161:7647)
    at EventEmitter.stopLoadingListener (node:electron/js2c/browser_init:161:8022)
    at EventEmitter.emit (node:events:390:28)
    at EventEmitter.emit (node:domain:475:12)
error Command failed with exit code 1.

Ops! I was running in Electron on the CI

@lmiller1990
Copy link
Contributor

Can you try the latest Cypress (10.2.0)? This PR landed which might help with memory issues: #22460

@gvocale
Copy link
Author

gvocale commented Jun 27, 2022

@lmiller1990 still running in the issue on electron with "cypress": "^10.2.0",. Seems #22460 will land in 10.2.1. I'll try it then as soon as it is released.

@lmiller1990
Copy link
Contributor

Right, I thought it went out already. Let's wait for the next release. Thanks.

@mjhenkes
Copy link
Member

@gvocale, could you try cypress 10.3.0 to see if it resolves your issue? A contributor recently fixed a memory leak.

@cypress-bot cypress-bot bot added stage: awaiting response Potential fix was proposed; awaiting response and removed stage: open labels Jun 28, 2022
@gvocale
Copy link
Author

gvocale commented Jun 28, 2022

@mjhenkes no luck, failing on cy when using electron with "cypress": "^10.3.0",

ERR_FAILED (-2) loading 'http://localhost:8080/__/#/specs/runner?file=src/dct/components/Checkout/CardForm/CardForm.cy.tsx'
Error: ERR_FAILED (-2) loading 'http://localhost:8080/__/#/specs/runner?file=src/dct/components/Checkout/CardForm/CardForm.cy.tsx'
    at rejectAndCleanup (node:electron/js2c/browser_init:161:7647)
    at EventEmitter.stopLoadingListener (node:electron/js2c/browser_init:161:8022)
    at EventEmitter.emit (node:events:390:28)
    at EventEmitter.emit (node:domain:475:12)
────────────────────────────────────────────────────────────────────────────────────────────────────
  Running:  ChosenShippingMethods.cy.tsx(121 of 226)
Unhandled rejection Error: ERR_FAILED (-2) loading 'about:blank'
    at rejectAndCleanup (node:electron/js2c/browser_init:161:7647)
    at EventEmitter.stopLoadingListener (node:electron/js2c/browser_init:161:8022)
    at EventEmitter.emit (node:events:390:28)
    at EventEmitter.emit (node:domain:475:12)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: The process '/usr/local/bin/yarn' failed with exit code 1

@lmiller1990
Copy link
Contributor

Argh, no luck. I'll try to reproduce.

@JoaoTMDias I noticed you have on("file:preprocessor", webpackPreprocessor(options));. I don't think you need this with component testing - we automatically detect your webpack config when you do bundler: 'webpack' and apply the preprocessor.

@JoaoTMDias
Copy link

Argh, no luck. I'll try to reproduce.

@JoaoTMDias I noticed you have on("file:preprocessor", webpackPreprocessor(options));. I don't think you need this with component testing - we automatically detect your webpack config when you do bundler: 'webpack' and apply the preprocessor.

Thanks! That would be something that document would be helpful to read when I was migrating 🙂

@cypress-bot cypress-bot bot added stage: investigating Someone from Cypress is looking into this and removed stage: awaiting response Potential fix was proposed; awaiting response labels Jun 29, 2022
@lmiller1990
Copy link
Contributor

lmiller1990 commented Jun 29, 2022

I'm trying to reproduce this by running a lot of CT specs: https://github.com/lmiller1990/cra-cypresss-lots-of-specs/runs/7121846709?check_suite_focus=true.

We need a reliable reproduction to debug this. I tried reproducing: https://github.com/lmiller1990/cra-cypresss-lots-of-specs/actions/runs/2586378690. Super basic test, but there's 100 specs, each runs 10 tests - no dice.

Edit: dup of #22353?

@cypress-bot cypress-bot bot added stage: awaiting response Potential fix was proposed; awaiting response and removed stage: investigating Someone from Cypress is looking into this labels Jun 30, 2022
@mjhenkes
Copy link
Member

Closing as a duplicate of #22353
Could you continue discussions on the linked issue?

@lmiller1990
Copy link
Contributor

Same as #22663 I think!

@panzarino
Copy link
Contributor

panzarino commented Aug 26, 2022

I am still running into this issue regularly when running tests in CI on the latest version (10.6.0). Given that we're building an electron app, we don't want to use Chrome to resolve these issues (even though they're basically the same). It appears the aforementioned electron upgrade hasn't fixed this problem.

For more context, here's an example of what we're running into (it's slightly different, so maybe warrants a new issue, but the loading about:blank is still present)

Could not process 'reset:browser:tabs:for:next:test'. No automation clients connected.
Error: Could not process 'reset:browser:tabs:for:next:test'. No automation clients connected.
    at SocketCt.onAutomation (C:\Users\circleci\project\.cache\Cypress\10.6.0\Cypress\resources\app\packages\server\lib\socket-base.js:88:15)
    at onAutomationClientRequestCallback (C:\Users\circleci\project\.cache\Cypress\10.6.0\Cypress\resources\app\packages\server\lib\socket-base.js:135:25)
    at C:\Users\circleci\project\.cache\Cypress\10.6.0\Cypress\resources\app\packages\server\lib\automation\automation.js:77:20
    at Promise.cancellationExecute [as _execute] (C:\Users\circleci\project\.cache\Cypress\10.6.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\debuggability.js:406:9)
    at Promise._resolveFromExecutor (C:\Users\circleci\project\.cache\Cypress\10.6.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\promise.js:518:18)
    at new Promise (C:\Users\circleci\project\.cache\Cypress\10.6.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\promise.js:103:10)
    at Automation.requestAutomationResponse (C:\Users\circleci\project\.cache\Cypress\10.6.0\Cypress\resources\app\packages\server\lib\automation\automation.js:62:16)
    at C:\Users\circleci\project\.cache\Cypress\10.6.0\Cypress\resources\app\packages\server\lib\automation\automation.js:58:52
    at C:\Users\circleci\project\.cache\Cypress\10.6.0\Cypress\resources\app\packages\server\lib\automation\automation.js:122:28
    at tryCatcher (C:\Users\circleci\project\.cache\Cypress\10.6.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\util.js:16:23)
    at Function.Promise.attempt.Promise.try (C:\Users\circleci\project\.cache\Cypress\10.6.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\method.js:39:29)
    at Automation.normalize (C:\Users\circleci\project\.cache\Cypress\10.6.0\Cypress\resources\app\packages\server\lib\automation\automation.js:90:38)
    at C:\Users\circleci\project\.cache\Cypress\10.6.0\Cypress\resources\app\packages\server\lib\automation\automation.js:153:25
    at tryCatcher (C:\Users\circleci\project\.cache\Cypress\10.6.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\util.js:16:23)
    at Promise._settlePromiseFromHandler (C:\Users\circleci\project\.cache\Cypress\10.6.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\promise.js:547:31)
    at Promise._settlePromise (C:\Users\circleci\project\.cache\Cypress\10.6.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\promise.js:604:18)
    at Promise._settlePromiseCtx (C:\Users\circleci\project\.cache\Cypress\10.6.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\promise.js:641:10)
    at _drainQueueStep (C:\Users\circleci\project\.cache\Cypress\10.6.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\async.js:97:12)
    at _drainQueue (C:\Users\circleci\project\.cache\Cypress\10.6.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\async.js:86:9)
    at Async._drainQueues (C:\Users\circleci\project\.cache\Cypress\10.6.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (C:\Users\circleci\project\.cache\Cypress\10.6.0\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\async.js:15:14)
    at processImmediate (node:internal/timers:466:21)

ERR_FAILED (-2) loading 'about:blank'
Error: ERR_FAILED (-2) loading 'about:blank'
    at rejectAndCleanup (node:electron/js2c/browser_init:161:7647)
    at EventEmitter.stopLoadingListener (node:electron/js2c/browser_init:161:8022)
    at EventEmitter.emit (node:events:526:28)
    at EventEmitter.emit (node:domain:475:12)

@lmiller1990
Copy link
Contributor

Hi @panzarino, long time no see.

Question... is this for component testing (as the issue suggests) or E2E? about:blank sounds like it's more in the E2E area, although I wonder if we also load that before the initial spec launches in Component Testing.

If it is indeed component testing, out of curiosity can you try using the experimentalSingleTabRunMode experiment? See Docs and see if this makes a difference? Shot in the dark - I haven't found the source of the crashing, but this might give us some more insight.

@panzarino
Copy link
Contributor

panzarino commented Aug 27, 2022

Yeah this is only happening on component testing (e2e has no problems) - I'll give that experimental option a try and see if it fixes anything.

Not sure if it matters, but sometimes we get failures like this for our first spec, sometimes for last, sometimes somewhere in the middle. I'm not sure if the errors are always the same (I'll try to report any different ones), but about half of all component test runs in CI are currently failing for things outside of our control like this.

@lmiller1990
Copy link
Contributor

lmiller1990 commented Aug 29, 2022

Hmm ok, thanks for the context. I just checked and we run all ours in Chrome - I'll try running in Electron, I'm guessing we will see the same problem.

I wonder why this only manifests in Electron... I wonder if either we have an Electron-specific memory leak, or there's a memory leak due to how we use Electron. If it was a memory issue, I'd expect it to be more consistent (like the original OP described) not random, though.

@canadianakin
Copy link

This error is popping up for me in a GitLab SaaS runner when running with the electron browser, with only 15 component tests. I believe it is resource related. Those runners have 1vCPU and 3.75gb of memory.

When I run tests locally in the same docker container the runner is using, and constrain it to those specs, the error consistently appears. When I give the container a bit more juice the errors go away.

Possibly related, but I am seeing what looks like tests running before the webpack finishes compilation with electron. Cypress tries to connect to the electron browser, times out, and then I see webpack compiled successfully. I've seen Cypress attempt to connect up to two times before compilation finishes, and the tests are duplicated by the amount of attempted connections.

@lmiller1990
Copy link
Contributor

I think it's fine to connect to the browser while webpack is compiling - Cypress will wait until webpack compiles to actually run the tests, but no need to block on bundling while the browser opens.

Are you able to share a docker container than reproduces this consistently? That would greatly help with debugging.

I also think it's a resource issue. Most of my projects are using Vite, so I don't notice it - I wonder if webpack is more of a memory hog 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CT Issue related to component testing existing workaround stage: awaiting response Potential fix was proposed; awaiting response type: bug v10.0.2 🐛 Issue present since 10.0.2
Projects
None yet
Development

No branches or pull requests

7 participants