{"record":{"id":"e12ad09ca40b735e","repo":"cypress-io/cypress","slug":"no-project","errorCode":"NO_PROJECT","errorMessage":"A project must be open prior to attempting to run a spec","messagePattern":"A project must be open prior to attempting to run a spec","errorType":"error_code","errorClass":"RunSpecError","httpStatus":null,"severity":"error","filePath":"packages/data-context/src/actions/ProjectActions.ts","lineNumber":520,"sourceCode":"      let maxIterations = 3\n\n      while (this.ctx.coreData.app.browserStatus !== 'open') {\n        await Promise.race([\n          new Promise((resolve) => setTimeout(resolve, 1000)),\n          browserStatusSubscription.next(),\n        ])\n\n        if (--maxIterations === 0) {\n          break\n        }\n      }\n\n      await browserStatusSubscription.return(undefined as any)\n    }\n\n    try {\n      if (!this.ctx.currentProject) {\n        throw new RunSpecError('NO_PROJECT', 'A project must be open prior to attempting to run a spec')\n      }\n\n      if (!specPath) {\n        throw new RunSpecError('NO_SPEC_PATH', '`specPath` must be a non-empty string')\n      }\n\n      let targetTestingType: TestingType\n\n      // Get relative path from the specPath to determine which testing type from the specPattern\n      const relativeSpecPath = path.relative(this.ctx.currentProject, specPath)\n\n      // Check to see whether input specPath matches the specPattern for one or the other testing type\n      // If it matches neither then we can't run the spec and we should error\n      if (await this.ctx.project.matchesSpecPattern(relativeSpecPath, 'e2e')) {\n        targetTestingType = 'e2e'\n      } else if (await this.ctx.project.matchesSpecPattern(relativeSpecPath, 'component')) {\n        targetTestingType = 'component'\n      } else {","sourceCodeStart":502,"sourceCodeEnd":538,"githubUrl":"https://github.com/cypress-io/cypress/blob/0d85fdc91230885bca0a91df278312800a48b727/packages/data-context/src/actions/ProjectActions.ts#L502-L538","documentation":"Thrown by ProjectActions.runSpec (ProjectActions.ts:519-521) with code NO_PROJECT when this.ctx.currentProject is null at the moment runSpec is invoked. runSpec is the action that launches a specific spec file; it needs an active, opened project to resolve the spec path against. The error is wrapped into a RunSpecError and the surrounding catch returns { code: 'NO_PROJECT', detailMessage } rather than rethrowing, so callers receive a structured result, not a thrown exception.","triggerScenarios":"Calling the runSpec mutation/action before a project has been opened/initialized (currentProject still null). Happens if the GraphQL runSpec mutation fires during launchpad onboarding before openProject completes, or after a project was closed/errored and currentProject was reset to null.","commonSituations":"Race during launchpad startup where the UI triggers a run before project open finishes; a previous project-open failed and left currentProject null; the user backed out to project selection and a stale run request fired; programmatic/automated driver that calls runSpec without first opening a project.","solutions":["Ensure a project is opened first (await the openProject/launchProject flow) and that ctx.currentProject is set before invoking runSpec.","If this appears after an error, check why currentProject is null (prior open failure, config error in diagnostics) and re-open the project.","In the UI/GraphQL layer, disable the run-spec control until currentProject is non-null."],"exampleFix":"// before\nconst result = await ctx.actions.runSpec({ specPath })\n\n// after\nif (!ctx.currentProject) {\n  await ctx.actions.openProject(/* ... */) // finish opening first\n}\nconst result = await ctx.actions.runSpec({ specPath })","handlingStrategy":"validation","validationCode":"// Validate project-open state before invoking runSpec\nfunction canRunSpec(ctx: DataContext): boolean {\n  return ctx.currentProject != null\n}\n\nif (!canRunSpec(ctx)) {\n  // open a project first, or surface the requirement to the launchpad\n  return\n}\nconst result = await ctx.actions.runSpec({ specPath })","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat the runSpec result shape, not a thrown error: it returns { code, detailMessage } on failure — branch on result.code === 'NO_PROJECT' rather than expecting an exception.","Gate the run-spec UI control on ctx.currentProject being non-null.","After any project-open error, reset UI state so a stale run request cannot fire against a null currentProject."],"tags":["runspec","project-state","launchpad","race-condition"],"backgroundTag":null,"analyzedSha":"0d85fdc91230885bca0a91df278312800a48b727","analyzedAt":"2026-08-12T16:24:28.056Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}