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 hangs on "initializing config" when opening with --e2e flag - fresh install on new project #25974

Closed
marktnoonan opened this issue Feb 28, 2023 · 20 comments
Labels
E2E Issue related to end-to-end testing Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team.

Comments

@marktnoonan
Copy link
Contributor

marktnoonan commented Feb 28, 2023

Created this based on comment in #21920

I'm having the same situation with 12.7 after a fresh install (Cypress was never used in this project).

Peek 2023-02-28 15-05

It just hangs forever, no message in DevTools or console.

I'm on Ubuntu 22.10, Node 18.14.2. I use Cypress a lot in other projects without issue.

Originally posted by @yktoo in #21920 (comment)

@marktnoonan
Copy link
Contributor Author

@yktoo if Cypress works fine in other projects on the same OS and node version I would be interested in seeing the config for the project you've just added Cypress to (it may be empty I guess?), or if you could capture logs with DEBUG=cypress:*, there is probably some useful information logged there that would tell us how far Cypress gets in this step.

@yktoo
Copy link

yktoo commented Feb 28, 2023

I believe this only happens when trying to start Cypress for the first time (no config or tests present), while giving the --e2e argument:

cypress open --e2e

When started without arguments, it opens normally.

Still, I think it's a bug, which better be fixed.

@marktnoonan
Copy link
Contributor Author

Ah that's a good observation, thank you.

@marktnoonan marktnoonan changed the title Cypress hangs on "initializing config" - fresh install on new project Cypress hangs on "initializing config" when opening with --e2e flag - fresh install on new project Feb 28, 2023
@mike-plummer
Copy link
Contributor

@marktnoonan I have not been able to reproduce this using Cy 12.7.0 on Mac 13.2.1. Did you say you managed to reproduce this? Was it Linux and/or shell-specific?

@marktnoonan
Copy link
Contributor Author

marktnoonan commented Mar 3, 2023

@mike-plummer here's a loom

We don't have a great experience for opening an unconfigured testing type with a CLI flag, it felt a bit disorienting even when it works (after configuring CT, you can use --e2e just fine because you don't get the error. But I guess that's a side note.

Opening with --component works with no config file present, though framework and bundler detection didn't seem to look right.

It's possible if a testing type is not configured, we should ignore the flag and start at the testing type picker to just have one on-ramp.

@mike-plummer
Copy link
Contributor

I was unable to reproduce this on a fresh setup of Cypress as described above, but there is a problem where a new Cypress config is set up against an existing /cypress directory that causes a malformed config - an error in this flow presents as a hang and is not shown to the user until a subsequent relaunch of Cypress. For example, the following steps can reproduce the issue:

  1. Copy the contents of system-tests/projects/vue3-vite-ts-configured to a new directory, install dependencies npm i
  2. Delete the cypress.config.ts file: rm cypress.config.ts
  3. Add Cypress as a dependency: npm i -D cypress
  4. Open Cypress into e2e mode: npx cypress open --e2e
  5. Launchpad should scaffold new configs
  6. Attempt to proceed, app will hang with "Initializing config..."
  7. Close and reopen Cypress using above command, Launchpad will now show the error that killed the previous run (multiple support files matching pattern)

@NaClYen
Copy link

NaClYen commented Mar 9, 2023

In my case, I tried to import the with-cypress example into my existing project, but I forgot to copy the cypress.config.ts file. As a result, I encountered a hang.

According to @yktoo's observation, I removed the --e2e option, and it worked. Now, whether the --e2e option exists or not, everything works great.

Hope this helped.

@nagash77 nagash77 added E2E Issue related to end-to-end testing Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. and removed routed-to-e2e labels Apr 19, 2023
@amenk
Copy link

amenk commented May 5, 2023

I believe this only happens when trying to start Cypress for the first time (no config or tests present), while giving the --e2e argument:

cypress open --e2e

When started without arguments, it opens normally.

Still, I think it's a bug, which better be fixed.

We are using yarn cypress:open --browser chrome --e2e open the tests directly without further clicks.
Without --e2e it starts fast, but then when clicking "open E2E in chrome" it takes a long time.
Not sure if this is the same issue. It happens on each start - not only the first one. Also we are providing the base URL in the command.

This seems to happen since the update from 9->12

Is there more debugging info needed?

@mike-plummer
Copy link
Contributor

@amenk It sounds like in your situation it takes a little while to open but eventually does and Cypress is usable. This particular issue describes an infinite hang (Cypress never finishes opening).

You're welcome to open a separate issue describing the behavior you're seeing - all the pieces of information that we need are called out in the new issue template. The most important and useful is a reproduction case so we can debug and identify the problem. Be aware that this sort of issue is often related to plugins or other logic triggering from your cypress.config.js file.

@amenk
Copy link

amenk commented May 6, 2023

@mike-plummer thanks, sure: #26684

@MikeMcC399
Copy link
Contributor

MikeMcC399 commented May 9, 2023

@lmiller1990 lmiller1990 removed their assignment Jun 28, 2023
@Dmitry-Boyko
Copy link

Dmitry-Boyko commented Jun 29, 2023

Hello,
So, Cypress, what the steps to fix "Initializing config..." issue?
image
image

Overnight running with clear Console.
v12.16.0

@yktoo
Copy link

yktoo commented Jun 29, 2023

@Dmitry-Boyko did you try starting it without the --e2e flag?

@Dmitry-Boyko
Copy link

Dmitry-Boyko commented Jun 29, 2023

@yktoo please see the second screenshot.
Terminal command: yarn open:prod
Then show up page with setting and button "Continue" was enable.
I clicked on this button.

@yktoo
Copy link

yktoo commented Jun 29, 2023

@Dmitry-Boyko not sure what you mean by that. This issue is specifically about a problem when Cypress is first-time run with --e2e.

What's your command to start Cypress UI?

@Dmitry-Boyko
Copy link

@yktoo This is first-time run, correct

@mike-plummer
Copy link
Contributor

@Dmitry-Boyko The "Initializing Cypress" stage should only take a few seconds (depending on the complexity of your project and your computer hardware) - if it's taking more than a few minutes that tells me that something is wrong and it's not going to finish. This issue is specifically for the behavior of the "Initializing cypress" stage hanging when launched with the --e2e CLI flag. If you're encountering this behavior when not using that flag then you may have identified a different bug and should report it as a new issue. We would need Debug Logs and, ideally, a reproducible example so we can troubleshoot.

@Dmitry-Boyko
Copy link

Dmitry-Boyko commented Jun 29, 2023

Thank you @mike-plummer and @yktoo
I fired up cypress with DEBUG=cypress:* yarn open:prod --browser chrome --e2e = error => cypress:lifecycle:ProjectConfigManager catch { name: 'Error', message: 'Your \x1B[33mconfigFile\x1B[39m is invalid: \x1B[94mC:\workspace\work-path39m\n' + '\n' + 'It threw an error when required, check the stack trace below:', stack: "Error: Cannot find module 'C:\workspace\work-path\e2e-kl\ stack:\n' + ....
DEBUG=cypress:cli yarn open:prod --browser chrome --e2e` =error=> cypress:cli piping child STDERR to process STDERR +1ms
With DEBUG=cypress:* yarn open:prod --browser chrome --e2e I got huge log, don't know where I can post it

@mike-plummer
Copy link
Contributor

@Dmitry-Boyko Your error contains the message "Your configFile is invalid" which likely means you either have an old config file that no longer complies with the required format or you are somehow specifying a configFile path that does not exist (more likely considering the "Cannot find module" part of the message. Additional information should be evident from the stacktrace in the logs.

What you are experiencing appears to be a local configuration issue, not a bug in Cypress. While the symptom is similar to that seen here you likely need to investigate the open:prod yarn script you're using to launch Cypress (this is part of your project, not provided by Cypress) as it is probably adding a --configFile parameter that doesn't work on your computer. If you are unable to determine the problem you should reach out to the community on Discord which is better suited to address questions about how to use Cypress.

@Dmitry-Boyko
Copy link

Thank you @mike-plummer !
Works now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E2E Issue related to end-to-end testing Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team.
Projects
None yet
Development

No branches or pull requests

9 participants