fix(FN-4429): harden step-session abort path on user cancel

Fusion-Task-Id: FN-4429
Fusion-Task-Lineage: b010437b-0e58-43f6-81b3-40dcebbf0873
This commit is contained in:
Fusion
2026-05-14 10:21:12 -07:00
committed by gsxdsm
parent d9b43b9507
commit 40fee0c128
2 changed files with 8 additions and 5 deletions

View File

@@ -12,8 +12,9 @@ describe("TaskExecutor user cancel handling", () => {
const callOrder: string[] = [];
const session = {
prompt: vi.fn(),
abort: vi.fn(async () => {
abort: vi.fn(() => {
callOrder.push("abort");
return Promise.resolve();
}),
dispose: vi.fn(() => {
callOrder.push("dispose");

View File

@@ -1197,11 +1197,13 @@ export class TaskExecutor {
this.pausedAborted.add(task.id);
this.options.stuckTaskDetector?.untrackTask(task.id);
const stepExecutor = this.activeStepExecutors.get(task.id)!;
const stepExecutorWithAbort = stepExecutor as StepSessionExecutor & { abortAllSessionBash?: () => Promise<void> };
const stepExecutorWithAbort = stepExecutor as StepSessionExecutor & { abortAllSessionBash?: () => void };
if (typeof stepExecutorWithAbort.abortAllSessionBash === "function") {
void stepExecutorWithAbort.abortAllSessionBash().catch((err) =>
executorLog.warn(`Failed to abort step-session bash for ${task.id}: ${err}`),
);
try {
stepExecutorWithAbort.abortAllSessionBash();
} catch (err) {
executorLog.warn(`Failed to abort step-session bash for ${task.id}: ${err}`);
}
}
stepExecutor.terminateAllSessions().catch((err) =>
executorLog.error(`Failed to terminate step sessions for ${task.id}:`, err),