mastra-ai/mastra · error · Error
Operation terminated by SIGTERM
Error message
Operation terminated by SIGTERM
What it means
During `create`, the CLI registers SIGINT/SIGTERM handlers and records the interruption signal; after materialization settles it re-checks them (create.ts:424). If SIGTERM was received while scaffolding, the run is aborted and a plain Error 'Operation terminated by SIGTERM' is thrown so the process exits non-zero instead of producing a half-written project.
Source
Thrown at packages/cli/src/commands/create/create.ts:424
await cleanupOwnedStagingDirectory(staging.rootPath);
} catch (cleanupError) {
console.error(
`Warning: Failed to clean up staging directory: ${cleanupError instanceof Error ? cleanupError.message : 'Unknown error'}`,
);
}
}
const platformSetup = await platformSetupPromise;
process.removeListener('SIGINT', handleSigint);
process.removeListener('SIGTERM', handleSigterm);
if (interruptionSignal === 'SIGINT') {
if (observabilityEnabled) {
analytics?.trackEvent('cli_observability_outcome', { command: 'create', outcome: 'cancelled' });
}
cancelCreate();
}
if (interruptionSignal === 'SIGTERM') throw new Error('Operation terminated by SIGTERM');
if (materializationError) throw materializationError;
if (platformSetup?.status === 'cancelled') {
analytics?.trackEvent('cli_observability_outcome', { command: 'create', outcome: 'skipped' });
p.log.info('Skipping Mastra platform setup.');
} else if (observabilityEnabled) {
p.log.success(
options.install
? 'Default template cloned and dependencies installed.'
: 'Default template cloned. Dependency installation was skipped.',
);
}
const postSetup = await runPostCreateSetup({
projectPath: targetPath,
installSkills: options.skills,
initializeGit: options.git,
invocationIsGitWorktree,
});View on GitHub (pinned to 75dd419e61)
Solutions
- Re-run `mastra create` after the terminating condition is gone
- Raise CI/step timeouts so long installs aren't killed mid-scaffold
- Run the command in a foreground terminal away from aggressive supervisors
- If under Docker/K8s, increase grace period (docker stop -t, terminationGracePeriodSeconds) or run create outside the ephemeral environment
Defensive patterns
Strategy: try-catch
Try / catch
try {
await create(opts);
} catch (error) {
if (error instanceof Error && error.message === 'Operation terminated by SIGTERM') {
console.error('Scaffold aborted by SIGTERM; target project may not exist — re-run create');
process.exitCode = 143; // conventional SIGTERM exit code
return;
}
throw error;
} Prevention
- Increase CI step timeouts so long installs aren't killed
- Avoid wrapping mastra create in supervisors that escalate to SIGTERM
- Use --timeout with a generous value to finish installs before external kills
- Check for stray partial directories after a SIGTERM before re-running
When it happens
Trigger: Something sends SIGTERM to `mastra create` mid-run: `kill <pid>`, container/CI timeout terminations, `pkill mastra`, orchestrators (Docker stop, Kubernetes) shutting down the job.
Common situations: CI jobs killed at a step timeout; IDE task runners stopping a dev command; Docker containers stopped before the scaffold finished; running the command under a supervisor that restarts it.
Related errors
- 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
- --continue and --thread cannot be used together
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/425f2a5e90a1b0c1.
Report an issue: GitHub.