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:
@@ -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");
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user