cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.49k stars 3.14k forks source link

open with --e2e in unconfigured monorepo hangs #29544

Open MikeMcC399 opened 1 month ago

MikeMcC399 commented 1 month ago

Current behavior

If Cypress is opened with

npx cypress open --e2e

in a subdirectory (monorepo) and Cypress is not configured (no cypress.config.* file present), then the Cypress Launchpad hangs showing "Initializing config..." and a rotating Cypress logo.

image

Desired behavior

Opening Cypress with

npx cypress open --e2e

in a subdirectory (monorepo) and Cypress is not configured, for instance without a cypress.config.js file, then the Cypress Launchpad should offer a browser option to continue the setup.

Test code to reproduce

git clone https://github.com/cypress-io/github-action
cd github-action
cd examples/basic
rm cypress.config.js
npm ci
npx cypress open --e2e

Cypress Version

First reported on version: 13.9.0 Reproducible also on: 13.11.0

Node version

v20.13.1, also v20.14.0

Operating System

Ubuntu 22.04.4 LTS

Debug Logs

open-hang.zip

Other

npx cypress open

(with no test type option specified), followed by the selection of E2E Testing through the Launchpad UI, works correctly.

If the following is executed in examples/basic, which causes a .git directory to be created in examples/basic, then the problem is no longer reproducible:

git init

Related

jennifer-shehane commented 1 month ago

I wonder if this is similar to the situation we sometimes see in our internal tests when there is no e2e/ct configured and it hangs: https://github.com/cypress-io/cypress/issues/29486

MikeMcC399 commented 1 month ago

@jennifer-shehane

  • I wonder if this is similar to the situation we sometimes see in our internal tests when there is no e2e/ct configured and it hangs: #29486

It does look very similar. The log file shows it going into a loop. One iteration shown below:

2024-05-21T11:09:51.157Z cypress:graphql:nexusDeferIfNotLoadedPlugin Racing CurrentProject.cloudProject resolved immediately
2024-05-21T11:09:51.157Z cypress:config:browser validating configuration {}
2024-05-21T11:09:51.157Z cypress:config:browser validating configuration {}
2024-05-21T11:09:51.160Z cypress:server:saved_state making saved state from /home/mike/.cache/Cypress/13.9.0/Cypress/resources/app/packages/server
2024-05-21T11:09:51.160Z cypress:server:saved_state missing project path, looking for project here
2024-05-21T11:09:51.161Z cypress:graphql:nexusDeferIfNotLoadedPlugin Racing execution for CurrentProject.cloudProject
2024-05-21T11:09:51.161Z cypress:graphql:nexusDeferIfNotLoadedPlugin Racing execution for Query.versions
2024-05-21T11:09:51.161Z cypress:graphql:nexusDeferIfNotLoadedPlugin Racing execution for Query.cloudViewer
2024-05-21T11:09:51.161Z cypress:graphql:remoteSchemaWrapped executing: {"operationName":"HeaderBar_HeaderBarQuery_cloudViewer","requestPolicy":"cache-first"}
2024-05-21T11:09:51.161Z cypress:graphql:nexusDeferIfNotLoadedPlugin Racing Query.cloudViewer resolved immediately
2024-05-21T11:09:51.161Z cypress:lifecycle:ProjectConfigManager catch { name: 'Error', message: 'Your configFile is invalid: /home/mike/github/tmp/github-action/examples/basic/cypress.config.js\n' + '\n' + 'It threw an error when required, check the stack trace below:', stack: "Error: Cannot find module '/home/mike/github/tmp/github-action/examples/basic/cypress.config.js'\n" + 'Require stack:\n' + '- /home/mike/.cache/Cypress/13.9.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_require_async_child.js\n' + '- /home/mike/.cache/Cypress/13.9.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/require_async_child.js\n' + '    at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)\n' + '    at Module._load (node:internal/modules/cjs/loader:986:27)\n' + '    at Module.require (node:internal/modules/cjs/loader:1233:19)\n' + '    at require (node:internal/modules/helpers:179:18)\n' + '    at loadFile (/home/mike/.cache/Cypress/13.9.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_require_async_child.js:89:14)\n' + '    at EventEmitter.<anonymous> (/home/mike/.cache/Cypress/13.9.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_require_async_child.js:116:38)\n' + '    at EventEmitter.emit (node:events:519:28)\n' + '    at process.<anonymous> (/home/mike/.cache/Cypress/13.9.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/util.js:33:22)\n' + '    at process.emit (node:events:519:28)\n' + '    at emit (node:internal/child_process:951:14)\n' + '    at process.processTicksAndRejections (node:internal/process/task_queues:83:21)', type: 'CONFIG_FILE_REQUIRE_ERROR', details: "Error: Cannot find module '/home/mike/github/tmp/github-action/examples/basic/cypress.config.js'\n" + 'Require stack:\n' + '- /home/mike/.cache/Cypress/13.9.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_require_async_child.js\n' + '- /home/mike/.cache/Cypress/13.9.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/require_async_child.js\n' + '    at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)\n' + '    at Module._load (node:internal/modules/cjs/loader:986:27)\n' + '    at Module.require (node:internal/modules/cjs/loader:1233:19)\n' + '    at require (node:internal/modules/helpers:179:18)\n' + '    at loadFile (/home/mike/.cache/Cypress/13.9.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_require_async_child.js:89:14)\n' + '    at EventEmitter.<anonymous> (/home/mike/.cache/Cypress/13.9.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_require_async_child.js:116:38)\n' + '    at EventEmitter.emit (node:events:519:28)\n' + '    at process.<anonymous> (/home/mike/.cache/Cypress/13.9.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/util.js:33:22)\n' + '    at process.emit (node:events:519:28)\n' + '    at emit (node:internal/child_process:951:14)\n' + '    at process.processTicksAndRejections (node:internal/process/task_queues:83:21)', isCypressErr: true, messageMarkdown: 'Your `configFile` is invalid: `/home/mike/github/tmp/github-action/examples/basic/cypress.config.js`\n' + '\n' + 'It threw an error when required, check the stack trace below:', originalError: { name: 'Error', message: "Cannot find module '/home/mike/github/tmp/github-action/examples/basic/cypress.config.js'\n" + 'Require stack:\n' + '- /home/mike/.cache/Cypress/13.9.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_require_async_child.js\n' + '- /home/mike/.cache/Cypress/13.9.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/require_async_child.js', stack: "Error: Cannot find module '/home/mike/github/tmp/github-action/examples/basic/cypress.config.js'\n" + 'Require stack:\n' + '- /home/mike/.cache/Cypress/13.9.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_require_async_child.js\n' + '- /home/mike/.cache/Cypress/13.9.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/require_async_child.js\n' + '    at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)\n' + '    at Module._load (node:internal/modules/cjs/loader:986:27)\n' + '    at Module.require (node:internal/modules/cjs/loader:1233:19)\n' + '    at require (node:internal/modules/helpers:179:18)\n' + '    at loadFile (/home/mike/.cache/Cypress/13.9.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_require_async_child.js:89:14)\n' + '    at EventEmitter.<anonymous> (/home/mike/.cache/Cypress/13.9.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_require_async_child.js:116:38)\n' + '    at EventEmitter.emit (node:events:519:28)\n' + '    at process.<anonymous> (/home/mike/.cache/Cypress/13.9.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/util.js:33:22)\n' + '    at process.emit (node:events:519:28)\n' + '    at emit (node:internal/child_process:951:14)\n' + '    at process.processTicksAndRejections (node:internal/process/task_queues:83:21)', code: 'MODULE_NOT_FOUND' } }
2024-05-21T11:09:51.162Z cypress:lifecycle:ProjectConfigManager catch { name: 'Error', message: 'Your configFile is invalid: /home/mike/github/tmp/github-action/examples/basic/cypress.config.js\n' + '\n' + 'It threw an error when required, check the stack trace below:', stack: "Error: Cannot find module '/home/mike/github/tmp/github-action/examples/basic/cypress.config.js'\n" + 'Require stack:\n' + '- /home/mike/.cache/Cypress/13.9.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_require_async_child.js\n' + '- /home/mike/.cache/Cypress/13.9.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/require_async_child.js\n' + '    at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)\n' + '    at Module._load (node:internal/modules/cjs/loader:986:27)\n' + '    at Module.require (node:internal/modules/cjs/loader:1233:19)\n' + '    at require (node:internal/modules/helpers:179:18)\n' + '    at loadFile (/home/mike/.cache/Cypress/13.9.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_require_async_child.js:89:14)\n' + '    at EventEmitter.<anonymous> (/home/mike/.cache/Cypress/13.9.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_require_async_child.js:116:38)\n' + '    at EventEmitter.emit (node:events:519:28)\n' + '    at process.<anonymous> (/home/mike/.cache/Cypress/13.9.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/util.js:33:22)\n' + '    at process.emit (node:events:519:28)\n' + '    at emit (node:internal/child_process:951:14)\n' + '    at process.processTicksAndRejections (node:internal/process/task_queues:83:21)', type: 'CONFIG_FILE_REQUIRE_ERROR', details: "Error: Cannot find module '/home/mike/github/tmp/github-action/examples/basic/cypress.config.js'\n" + 'Require stack:\n' + '- /home/mike/.cache/Cypress/13.9.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_require_async_child.js\n' + '- /home/mike/.cache/Cypress/13.9.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/require_async_child.js\n' + '    at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)\n' + '    at Module._load (node:internal/modules/cjs/loader:986:27)\n' + '    at Module.require (node:internal/modules/cjs/loader:1233:19)\n' + '    at require (node:internal/modules/helpers:179:18)\n' + '    at loadFile (/home/mike/.cache/Cypress/13.9.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_require_async_child.js:89:14)\n' + '    at EventEmitter.<anonymous> (/home/mike/.cache/Cypress/13.9.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_require_async_child.js:116:38)\n' + '    at EventEmitter.emit (node:events:519:28)\n' + '    at process.<anonymous> (/home/mike/.cache/Cypress/13.9.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/util.js:33:22)\n' + '    at process.emit (node:events:519:28)\n' + '    at emit (node:internal/child_process:951:14)\n' + '    at process.processTicksAndRejections (node:internal/process/task_queues:83:21)', isCypressErr: true, messageMarkdown: 'Your `configFile` is invalid: `/home/mike/github/tmp/github-action/examples/basic/cypress.config.js`\n' + '\n' + 'It threw an error when required, check the stack trace below:', originalError: { name: 'Error', message: "Cannot find module '/home/mike/github/tmp/github-action/examples/basic/cypress.config.js'\n" + 'Require stack:\n' + '- /home/mike/.cache/Cypress/13.9.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_require_async_child.js\n' + '- /home/mike/.cache/Cypress/13.9.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/require_async_child.js', stack: "Error: Cannot find module '/home/mike/github/tmp/github-action/examples/basic/cypress.config.js'\n" + 'Require stack:\n' + '- /home/mike/.cache/Cypress/13.9.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_require_async_child.js\n' + '- /home/mike/.cache/Cypress/13.9.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/require_async_child.js\n' + '    at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)\n' + '    at Module._load (node:internal/modules/cjs/loader:986:27)\n' + '    at Module.require (node:internal/modules/cjs/loader:1233:19)\n' + '    at require (node:internal/modules/helpers:179:18)\n' + '    at loadFile (/home/mike/.cache/Cypress/13.9.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_require_async_child.js:89:14)\n' + '    at EventEmitter.<anonymous> (/home/mike/.cache/Cypress/13.9.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_require_async_child.js:116:38)\n' + '    at EventEmitter.emit (node:events:519:28)\n' + '    at process.<anonymous> (/home/mike/.cache/Cypress/13.9.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/util.js:33:22)\n' + '    at process.emit (node:events:519:28)\n' + '    at emit (node:internal/child_process:951:14)\n' + '    at process.processTicksAndRejections (node:internal/process/task_queues:83:21)', code: 'MODULE_NOT_FOUND' } }
cacieprins commented 1 month ago

Sadly, this was not resolved by the fix for that flake. That flake was caused by a perpetual loading state in launchpad's Main.vue if the config file was in the process of being loaded by the Cypress server when the initial grapql query for that component was executed. It does look like it is related though - this loading screen is waiting on currentProject?.isFullConfigReady, which does not ever resolve to true in this case.

MikeMcC399 commented 1 month ago

@cacieprins

I retested on Cypress 13.11.0 and confirm that the issue still occurs. I've updated the original post accordingly.