{"record":{"id":"b30e2d245e26d68f","repo":"mastra-ai/mastra","slug":"createcancellederror","errorCode":null,"errorMessage":"CreateCancelledError","messagePattern":"CreateCancelledError","errorType":"exception","errorClass":"CreateCancelledError","httpStatus":null,"severity":"info","filePath":"packages/cli/src/commands/create/create.ts","lineNumber":128,"sourceCode":"    if (cancellationAnnounced) return;\n    cancellationAnnounced = true;\n    p.cancel('Operation cancelled');\n  };\n  const cancellation = new Promise<never>((_resolve, reject) => {\n    rejectCancellation = reject;\n  });\n  const abort = () => {\n    controller.abort();\n    announceCancellation();\n    rejectCancellation(new CreateCancelledError());\n  };\n  process.once('SIGINT', abort);\n\n  try {\n    const value = await Promise.race([prompt(controller.signal), cancellation]);\n    if (p.isCancel(value)) {\n      announceCancellation();\n      throw new CreateCancelledError();\n    }\n    return value;\n  } finally {\n    process.removeListener('SIGINT', abort);\n  }\n}\n\nasync function promptForProjectName(): Promise<string> {\n  return runCreatePrompt(signal =>\n    p.text({\n      message: 'What do you want to name your project?',\n      placeholder: 'my-mastra-app',\n      signal,\n      validate: value => {\n        if (!value || value.length === 0) return `Project name can't be empty`;\n        if (fsSync.existsSync(value)) {\n          return `A directory named \"${value}\" already exists. Please choose a different name.`;\n        }","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/cli/src/commands/create/create.ts#L110-L146","documentation":"`runCreatePrompt` in packages/cli/src/commands/create/create.ts:128 races each interactive prompt against a cancellation promise. If the user cancels the prompt (clack returns a cancel symbol) or SIGINT arrives, `announceCancellation()` runs and a `CreateCancelledError` is thrown. This keeps all interactive steps (project name, provider, API key, template selection) abortable and consistent.","triggerScenarios":"Pressing Ctrl+C or Esc during promptForProjectName, promptForProvider, promptForApiKey, or selectTemplate — clack's isCancel(value) becomes true and the error is thrown; SIGINT also rejects via the abort handler.","commonSituations":"User abandons setup because they lack an API key; terminal interrupt forwarded from a parent process; accidental Esc in the select list; answering 'cancel' on the clack confirm.","solutions":["Re-run `mastra create` and answer the prompts to completion","If you lack an API key, pass `--llm-api-key` (default flow only) to skip that prompt","Avoid pressing Esc/Ctrl+C in prompts; use the provided defaults","In automation, provide projectName/provider via CLI args so fewer prompts appear"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isCreateCancelled(e: unknown): e is CreateCancelledError {\n  return e instanceof CreateCancelledError;\n}","tryCatchPattern":"try {\n  await create({}); // fully interactive\n} catch (error) {\n  if (isCreateCancelledError(error)) {\n    console.log('Setup aborted by user; re-run mastra create anytime');\n    return;\n  }\n  throw error;\n}","preventionTips":["Esc/Ctrl+C during any clack prompt cancels the whole run — finish or pass args instead","Supply --llm-api-key/--llm to skip prompts that commonly cause abandonment","In wrappers, detect the clack cancel symbol pattern and exit cleanly"],"tags":["cli","cancellation","interactive-prompt","sigint"],"backgroundTag":"user-cancelled-operation","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}