{"record":{"id":"129f056b284b26c5","repo":"Hmbown/CodeWhale","slug":"worker-worker-id-no-longer-has-that-running-flee","errorCode":null,"errorMessage":"worker {worker_id} no longer has that running fleet task","messagePattern":"worker (.+?) no longer has that running fleet task","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/tui/src/fleet/manager.rs","lineNumber":1018,"sourceCode":"\n    pub fn interrupt_worker(&self, worker_id: &str) -> Result<FleetWorkerInspection> {\n        let state = self.ledger.rebuild_state()?;\n        let Some(task) = active_task_for_worker(&state, worker_id) else {\n            return Err(FleetControlError::NoActiveTask {\n                worker_id: worker_id.to_string(),\n            }\n            .into());\n        };\n        let cancelled = self.ledger.cancel_task_if_active(\n            &task.entry.run_id,\n            &task.entry.task_id,\n            Some(worker_id),\n            &timestamp(),\n            Some(\"operator\"),\n            Some(\"operator\"),\n        )?;\n        if !cancelled {\n            bail!(\"worker {worker_id} no longer has that running fleet task\");\n        }\n        self.refresh_run_status(&task.entry.run_id)?;\n        self.inspect_worker(worker_id)\n    }\n\n    pub fn restart_worker(&self, worker_id: &str) -> Result<FleetRestartReport> {\n        let state = self.ledger.rebuild_state()?;\n        let Some(task) = active_task_for_worker(&state, worker_id)\n            .or_else(|| latest_task_for_worker(&state, worker_id))\n        else {\n            bail!(\"worker {worker_id} has no fleet task to restart\");\n        };\n        let run = state\n            .runs\n            .get(&task.entry.run_id.0)\n            .ok_or_else(|| anyhow!(\"fleet run {} does not exist\", task.entry.run_id.0))?;\n        let max_workers = run\n            .max_workers","sourceCodeStart":1000,"sourceCodeEnd":1036,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/fleet/manager.rs#L1000-L1036","documentation":"FleetManager::interrupt_worker found an active task for the worker, but the ledger's cancel_task_if_active returned false, meaning the task was no longer active under that worker's lease at cancel time. This is a read-then-act race: between rebuilding state and cancelling, the task completed, was cancelled elsewhere, or its lease moved.","triggerScenarios":"Calling interrupt_worker(worker_id) concurrently with the worker finishing its task, another operator cancelling it, or a lease expiring and being taken over.","commonSituations":"Clicking stop in the UI just as the task completes; scripts that interrupt several workers in a loop while the scheduler reassigns work; double-invoked interrupt from a keybinding repeat.","solutions":["Re-inspect the worker (inspect_worker) to see its current task/status; if terminal, no interrupt is needed","Retry interrupt_worker if a new task is now active and still must be stopped","Treat the error as benign idempotency noise when the goal was simply 'make it stop'","Serialize operator commands per worker in UI/script code to avoid racing yourself"],"exampleFix":"// before\nmanager.interrupt_worker(&worker_id)?;\n\n// after\nmatch manager.interrupt_worker(&worker_id) {\n    Ok(inspection) => { /* cancelled */ }\n    Err(err) if err.to_string().contains(\"no longer has that running fleet task\") => {\n        let _ = manager.inspect_worker(&worker_id); // already moved on\n    }\n    Err(err) => return Err(err),\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match manager.interrupt_worker(&worker_id) {\n    Ok(inspection) => Ok(Some(inspection)),\n    Err(err) if err.to_string().contains(\"no longer has that running fleet task\") => {\n        Ok(None) // task already moved on; idempotent success\n    }\n    Err(err) => Err(err),\n}","preventionTips":["Refresh worker inspection right before interrupting in user-driven flows","Make interrupt handling idempotent in scripts; a missing task is success for 'stop it'","Avoid issuing duplicate interrupts for the same worker"],"tags":["fleet","race-condition","worker-control","rust","codewhale"],"backgroundTag":"command-race-conditional-check","analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}