{"record":{"id":"c005eb4c40d33e39","repo":"ruvnet/ruflo","slug":"no-active-task-to-checkpoint","errorCode":null,"errorMessage":"No active task to checkpoint","messagePattern":"No active task to checkpoint","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/integration/src/long-running-worker.ts","lineNumber":407,"sourceCode":"          checkpointId: this.checkpoints[this.checkpoints.length - 1]?.id,\n          progress: this.calculateProgress(),\n        },\n      };\n    } finally {\n      this.stopTimers();\n      this.currentLongTask = null;\n      this.abortController = null;\n    }\n  }\n\n  /**\n   * Save a checkpoint of the current execution state\n   *\n   * @returns Created checkpoint\n   */\n  async saveCheckpoint(): Promise<Checkpoint> {\n    if (!this.currentLongTask || !this.currentState) {\n      throw new Error('No active task to checkpoint');\n    }\n\n    this.checkpointSequence++;\n\n    const checkpoint: Checkpoint = {\n      id: `cp_${this.id}_${this.currentLongTask.id}_${this.checkpointSequence}`,\n      taskId: this.currentLongTask.id,\n      workerId: this.id,\n      sequence: this.checkpointSequence,\n      timestamp: Date.now(),\n      state: { ...this.currentState },\n      progress: this.calculateProgress(),\n      metadata: {\n        executionDuration: Date.now() - this.executionStartTime,\n      },\n    };\n\n    // Save to storage","sourceCodeStart":389,"sourceCodeEnd":425,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/integration/src/long-running-worker.ts#L389-L425","documentation":"Thrown by LongRunningWorker#saveCheckpoint (v3/@claude-flow/integration/src/long-running-worker.ts:407) when there is no currentLongTask/currentState — i.e. saveCheckpoint() was called while the worker is idle, not during task execution. Checkpoints snapshot in-flight state, so there is nothing to snapshot without an active task.","triggerScenarios":"Calling saveCheckpoint() from an external timer/webhook between tasks; calling after the task finished (currentLongTask was reset to null in the completion path just above the throw site); a monitoring loop checkpointing on a schedule regardless of task state.","commonSituations":"Periodic checkpoint schedulers that do not know task boundaries; retry logic that checkpoints after a task already completed; race where the task's finally block cleared state before your checkpoint call landed.","solutions":["Only checkpoint while a task runs — hook the worker's own lifecycle (progress/state-update events) instead of an external timer.","Guard the call: if (!worker.hasActiveTask) skip (or expose/track currentLongTask via a status getter).","If you need final state persisted, capture the task result at completion instead of checkpointing afterwards.","For periodic safety, subscribe to state-update callbacks and checkpoint inside them, where a task is guaranteed active."],"exampleFix":"// before\nsetInterval(() => worker.saveCheckpoint(), 30_000); // fires while idle -> throws\n\n// after\nworker.on('state-updated', async () => {\n  if (worker.getCurrentTaskId()) await worker.saveCheckpoint();\n});","handlingStrategy":"validation","validationCode":"if (worker.getCurrentTaskId?.() ?? worker['currentLongTask']) {\n  await worker.saveCheckpoint();\n} else {\n  logger.debug('skipping checkpoint: idle worker');\n}","typeGuard":"function hasActiveTask(w: { getCurrentTaskId?: () => string | null }): boolean {\n  return typeof w.getCurrentTaskId === 'function' && w.getCurrentTaskId() != null;\n}","tryCatchPattern":"try {\n  await worker.saveCheckpoint();\n} catch (e) {\n  if ((e as Error).message === 'No active task to checkpoint') return; // idle: nothing to do\n  throw e;\n}","preventionTips":["Checkpoint from state-update callbacks, not wall-clock timers.","Persist final state at task completion instead of checkpointing after the fact.","Treat 'no active task' as benign in periodic schedulers."],"tags":["checkpointing","invalid-state","long-running-worker","lifecycle"],"backgroundTag":"invalid-state-transition","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}