{"record":{"id":"66f67a3b67f137d9","repo":"ruvnet/ruflo","slug":"task-aborted","errorCode":null,"errorMessage":"Task aborted","messagePattern":"Task aborted","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"v3/@claude-flow/integration/src/long-running-worker.ts","lineNumber":656,"sourceCode":"  /**\n   * Core execution logic\n   *\n   * Override this in subclasses for custom long-running task implementations.\n   *\n   * @param task - Task to execute\n   * @returns Execution output\n   */\n  protected async executeCore(task: Task): Promise<AgentOutput> {\n    // Default implementation with standard execution phases\n    const phases: ExecutionPhase[] = [\n      { name: 'initialization', estimatedSteps: 1 },\n      { name: 'processing', estimatedSteps: 5 },\n      { name: 'finalization', estimatedSteps: 1 },\n    ];\n\n    for (const phase of phases) {\n      if (this.isAborted()) {\n        throw new Error('Task aborted');\n      }\n\n      for (let step = 1; step <= phase.estimatedSteps; step++) {\n        this.updateState(phase.name, step, phase.estimatedSteps);\n\n        // Phase processing time\n        await this.delay(100);\n\n        // Add partial result\n        this.updateState(phase.name, step, phase.estimatedSteps, {\n          phase: phase.name,\n          step,\n          timestamp: Date.now(),\n        });\n      }\n    }\n\n    return {","sourceCodeStart":638,"sourceCodeEnd":674,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/integration/src/long-running-worker.ts#L638-L674","documentation":"Thrown inside LongRunningWorker#executeCore (v3/@claude-flow/integration/src/long-running-worker.ts:656) at each phase boundary when this.isAborted() is true — i.e. the task's AbortController was triggered via the worker's abort API. It is cooperative cancellation: the default phase loop checks the abort flag between the initialization/processing/finalization phases and stops by throwing.","triggerScenarios":"Calling worker.abort(taskId) (or the configured abort entry point) while executeCore is between phases; timeouts built on abort; a supervisor cancelling long tasks on shutdown; aborting twice so a second run also sees the flag.","commonSituations":"User cancels a long-running job from the UI; a deadline timer fires abort; graceful shutdown aborting in-flight tasks; tests that abort and then assert on the rejection without recognizing this message.","solutions":["Treat 'Task aborted' as expected control flow: catch it and distinguish cancellation from real failures (check isAborted() or the abort reason) instead of reporting a crash.","Do not resume or reuse aborted work blindly — restart from the last checkpoint if you saved one.","For deadline-based aborts, surface 'cancelled by timeout' to callers rather than a raw error.","If abort was unexpected, find who called abort()/signalled the AbortController (supervisor, timeout, shutdown hook)."],"exampleFix":"// before\nconst out = await worker.execute(task);\n\n// after\ntry {\n  const out = await worker.execute(task);\n} catch (e) {\n  if ((e as Error).message === 'Task aborted') {\n    return { status: 'cancelled' };\n  }\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":"if (worker.isAborted?.()) {\n  // cancellation already requested: skip dispatch or return early\n  return { status: 'cancelled' };\n}","typeGuard":"function isAbortError(e: unknown): e is Error {\n  return e instanceof Error && e.message === 'Task aborted';\n}","tryCatchPattern":"try {\n  out = await worker.execute(task);\n} catch (e) {\n  if (isAbortError(e)) {\n    return { status: 'cancelled', reason: 'aborted by caller' }; // expected control flow\n  }\n  throw e;\n}","preventionTips":["Model cancellation as a first-class outcome in your task API, not an exception leak.","Checkpoint periodically so aborted tasks can resume instead of restarting.","Ensure abort timers are cleared on completion to avoid aborting the next task."],"tags":["abort","cancellation","long-running-worker","control-flow"],"backgroundTag":"task-aborted","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}