{"record":{"id":"d1b5737c3c5fefc3","repo":"mastra-ai/mastra","slug":"createcancellederror-operation-cancelled","errorCode":null,"errorMessage":"CreateCancelledError (Operation cancelled)","messagePattern":"CreateCancelledError \\(Operation cancelled\\)","errorType":"exception","errorClass":"CreateCancelledError","httpStatus":null,"severity":"info","filePath":"packages/cli/src/commands/create/create.ts","lineNumber":102,"sourceCode":"  llmProvider?: CreateLLMProvider;\n  llmApiKey?: string;\n  skills?: boolean;\n  git?: boolean;\n  template?: string | boolean;\n  timeout?: number;\n  analytics?: PosthogAnalytics;\n  resolveVersionTag?: () => Promise<string | undefined>;\n  install?: boolean;\n}\n\ntype PlatformSetupResult =\n  | { status: 'ready'; token: string; org: { orgId: string; orgName: string } }\n  | { status: 'cancelled' }\n  | { status: 'failed'; error: unknown };\n\nfunction cancelCreate(): never {\n  p.cancel('Operation cancelled');\n  throw new CreateCancelledError();\n}\n\nasync function runCreatePrompt<T>(prompt: (signal: AbortSignal) => Promise<T | symbol>): Promise<T> {\n  const controller = new AbortController();\n  let rejectCancellation: (error: CreateCancelledError) => void = () => {};\n  let cancellationAnnounced = false;\n  const announceCancellation = () => {\n    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());","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/cli/src/commands/create/create.ts#L84-L120","documentation":"`cancelCreate` in packages/cli/src/commands/create/create.ts:100 prints 'Operation cancelled' via @clack/prompts and throws `CreateCancelledError` (message 'Operation cancelled'). It is the canonical bail-out for user-initiated abandonment of the create flow, raised when SIGINT is received mid-run or when the user cancels an interactive template selection. It signals intentional cancellation, not a failure of the scaffolding itself.","triggerScenarios":"User presses Ctrl+C (SIGINT) during materialization — the SIGINT handler calls cancelCreate(); user aborts the interactive template picker (resolveTemplate calls cancelCreate when selection is falsy).","commonSituations":"Developer changes their mind mid-scaffold; slow dependency install prompts a Ctrl+C; accidental Ctrl+C while a prompt is open; CI pipeline aborts and delivers SIGINT to the process.","solutions":["This is expected behavior — re-run `mastra create` when ready and complete all prompts","Avoid Ctrl+C during scaffolding; the command cleans up its staging directory automatically","In scripts, treat CreateCancelledError as a normal exit (the CLI exits without a scary stack) rather than retrying","Wrap programmatic `create()` calls with isCreateCancelledError to skip error reporting for user cancellations"],"exampleFix":"// before\nawait create(options); // surfaces 'Operation cancelled' as an error\n// after\ntry {\n  await create(options);\n} catch (error) {\n  if (!isCreateCancelledError(error)) throw error;\n  // user cancelled — nothing to report\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"import { isCreateCancelledError } from './commands/create/create';\n// or inline:\nfunction isCancel(e: unknown): e is Error {\n  return e instanceof Error && e.name === 'CreateCancelledError';\n}","tryCatchPattern":"try {\n  await create(opts);\n} catch (error) {\n  if (isCreateCancelledError(error)) {\n    process.exitCode = 0; // user cancelled, not a failure\n    return;\n  }\n  throw error;\n}","preventionTips":["Don't send SIGINT to interactive CLI wizards in scripts; pre-answer prompts via flags","Treat 'Operation cancelled' as a normal exit path in wrappers","Provide all inputs via CLI args in automation so no prompt can be cancelled"],"tags":["cli","cancellation","sigint","control-flow"],"backgroundTag":"user-cancelled-operation","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}