can1357/oh-my-pi · warning · Error
Command aborted
Error message
Command aborted
What it means
The legacy bash command was aborted before completion (AbortSignal fired, typically by the user pressing Esc or the agent loop cancelling). The captured output snapshot is preserved with 'Command aborted' appended.
Source
Thrown at packages/coding-agent/src/extensibility/legacy-pi-coding-agent-shim.ts:391
};
try {
const result = await operations.exec(spawn.command, spawn.cwd, {
onData,
signal,
timeout,
env: spawn.env,
});
const snapshot = legacyBashSnapshot(output);
const text = snapshot.text || "(no output)";
if (result.exitCode !== 0 && result.exitCode !== null) {
throw new Error(appendStatus(text, `Command exited with code ${result.exitCode}`));
}
return { content: [{ type: "text", text }], details: snapshot.details };
} catch (err) {
const snapshot = legacyBashSnapshot(output);
const text = snapshot.text;
if (err instanceof Error && err.message === "aborted") {
throw new Error(appendStatus(text, "Command aborted"));
}
if (err instanceof Error && err.message.startsWith("timeout:")) {
throw new Error(appendStatus(text, `Command timed out after ${err.message.slice("timeout:".length)} seconds`));
}
throw err;
}
}
/**
* Convert an image attachment to PNG using the legacy package-root contract.
*
* Invalid or unsupported image data returns `null`, matching Pi's historical
* helper instead of surfacing Bun's decoder error to extensions.
*/
export async function convertToPng(
base64Data: string,
mimeType: string,
): Promise<{ data: string; mimeType: string } | null> {View on GitHub (pinned to 9690622007)
Solutions
- Re-run the command if the abort was unintentional
- For long commands, reduce runtime or run in background so aborts are less likely
- Avoid issuing user aborts while critical commands run
- Handle 'Command aborted' distinctly from failures in agent retry logic (it is a cancellation, not a command error)
Defensive patterns
Strategy: try-catch
Type guard
function isAbort(e: unknown): boolean { return e instanceof Error && e.message.includes('Command aborted'); } Try / catch
try { await bashTool.execute({ command }, { signal }); } catch (err) {
if (err instanceof Error && err.message.includes('Command aborted')) {
return { status: 'cancelled', partialOutput: err.message };
}
throw err;
} Prevention
- Register AbortSignal handlers and treat aborts as intentional cancellations
- Avoid starting long-running commands right before user-facing interactive steps
- Break long work into smaller commands so aborts lose less progress
- Distinguish aborted (cancel) from non-zero exit (failure) in retry logic
When it happens
Trigger: executeLegacyBashOperations' spawn rejects with err.message === 'aborted' because the AbortSignal passed to the spawn was triggered mid-run.
Common situations: User interrupts a long-running command from the TUI; agent framework cancels the tool call due to turn abort or timeout of the surrounding request; session shutdown while a command runs.
Related errors
- Command exited with code ${result.exitCode}
- Command timed out after ${err.message.slice("timeout:".lengt
- ${annotated || "Command aborted"}
- ${message}
- operation canceled
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/9c867da8eac91888.
Report an issue: GitHub.