mastra-ai/mastra · info · CreateCancelledError
CreateCancelledError
Error message
CreateCancelledError
What it means
`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.
Source
Thrown at packages/cli/src/commands/create/create.ts:128
if (cancellationAnnounced) return;
cancellationAnnounced = true;
p.cancel('Operation cancelled');
};
const cancellation = new Promise<never>((_resolve, reject) => {
rejectCancellation = reject;
});
const abort = () => {
controller.abort();
announceCancellation();
rejectCancellation(new CreateCancelledError());
};
process.once('SIGINT', abort);
try {
const value = await Promise.race([prompt(controller.signal), cancellation]);
if (p.isCancel(value)) {
announceCancellation();
throw new CreateCancelledError();
}
return value;
} finally {
process.removeListener('SIGINT', abort);
}
}
async function promptForProjectName(): Promise<string> {
return runCreatePrompt(signal =>
p.text({
message: 'What do you want to name your project?',
placeholder: 'my-mastra-app',
signal,
validate: value => {
if (!value || value.length === 0) return `Project name can't be empty`;
if (fsSync.existsSync(value)) {
return `A directory named "${value}" already exists. Please choose a different name.`;
}View on GitHub (pinned to 75dd419e61)
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
Defensive patterns
Strategy: try-catch
Type guard
function isCreateCancelled(e: unknown): e is CreateCancelledError {
return e instanceof CreateCancelledError;
} Try / catch
try {
await create({}); // fully interactive
} catch (error) {
if (isCreateCancelledError(error)) {
console.log('Setup aborted by user; re-run mastra create anytime');
return;
}
throw error;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- CreateCancelledError (Operation cancelled)
- Invalid --region "${region}". Expected one of: eu, us.
- ${err instanceof Error ? err.message : String(err)}\nYou can
- No organization matched --org "${value}". Available: ${avail
- Directory ${path.basename(targetPath)} already exists
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/b30e2d245e26d68f.
Report an issue: GitHub.