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

CT framework detection can fail due to open mode not waiting for DataContext to initialize #26388

Closed
mike-plummer opened this issue Mar 31, 2023 · 3 comments · Fixed by #26437
Assignees
Labels
CT Issue related to component testing type: bug

Comments

@mike-plummer
Copy link
Contributor

Current behavior

See packages/server/lib/modes/index.ts - this file kicks off an initialization of the data context for the current mode and executes a script based on the mode to launch the UI. The promise is passed into those scripts.
In run.ts the promise is awaited prior to reporting a "ready" state, but in interactive.ts it is not. This allows the UI to initialize prior to the data context being ready which can result in odd race conditions since not all GQL queries are reactive/subscriptions.

We need to evaluate whether an await is needed in interactive.ts to ensure this data is resolved prior to launching UI, or whether this is intentionally ignored for performance reasons

Desired behavior

No response

Test code to reproduce

  1. Add an arbitrary delay to packages/scaffold-config/src/detect.ts in the detectFramework function of several seconds

  2. Create a new CT project but do not initialize with a cypress config: npm create vite@latest. Install dependencies in project.

  3. Open project directly into CT mode: yarn dev --component --project <path to new project>

  4. Delay will prevent auto-detection of CT framework from resolving prior to UI being initialized

  5. Add an await of the _loading promise in interactive.ts

  6. Repeat test above, observe framework is now properly resolved

Cypress Version

12.8.1

Node version

16.17.1

Operating System

any

Debug Logs

No response

Other

No response

@emilyrohrbough
Copy link
Member

@mike-plummer FYI - We def do not want to await for this before launching the launchpad. We have found this to be is quite "slow" when analyzing our timings and this would make the open mode experience pretty "non-responsive".

@mike-plummer
Copy link
Contributor Author

@emilyrohrbough Was just going to ping you on this today to see if you remembered why it was structured that way 😆 . Thanks for the info (and amazing memory!). This was my assumption/fear, so we can work around it with a GQL subscription to get updated data once the context settles down behind the UI. I will plan to add some comments under this issue to interactive.ts to make it clear that we don't want to wait for that loading promise and why just for posterity

@mike-plummer mike-plummer changed the title open mode does not wait for DataContext to intialize prior to launching UI CT framework detection can fail due to open mode not waiting for DataContext to initialize Apr 5, 2023
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Apr 17, 2023

Released in 12.10.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v12.10.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Apr 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CT Issue related to component testing type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants