Skip to content

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

Closed
@mike-plummer

Description

@mike-plummer

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

Metadata

Metadata

Assignees

Labels

CTIssue related to component testingtype: bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions