{"record":{"id":"aaa80e4e06e99d6d","repo":"spacedriveapp/spacedrive","slug":"system-channel-closed-trying-to-resume-task","errorCode":null,"errorMessage":"System channel closed trying to resume task","messagePattern":"System channel closed trying to resume task","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/task-system/src/system.rs","lineNumber":525,"sourceCode":"\t}\n\n\tpub fn resume_task(\n\t\t&self,\n\t\ttask_id: TaskId,\n\t\ttask_work_table: Arc<TaskWorktable>,\n\t\tack: oneshot::Sender<Result<(), SystemError>>,\n\t) {\n\t\tlet system_tx = self.0.clone();\n\t\tspawn(\n\t\t\tasync move {\n\t\t\t\tsystem_tx\n\t\t\t\t\t.send(SystemMessage::ResumeTask {\n\t\t\t\t\t\ttask_id,\n\t\t\t\t\t\ttask_work_table,\n\t\t\t\t\t\tack,\n\t\t\t\t\t})\n\t\t\t\t\t.await\n\t\t\t\t\t.expect(\"System channel closed trying to resume task\");\n\t\t\t}\n\t\t\t.in_current_span(),\n\t\t);\n\t}\n\n\tpub fn force_abortion(\n\t\t&self,\n\t\ttask_id: TaskId,\n\t\ttask_work_table: Arc<TaskWorktable>,\n\t\tack: oneshot::Sender<Result<(), SystemError>>,\n\t) {\n\t\tlet system_tx = self.0.clone();\n\t\tspawn(\n\t\t\tasync move {\n\t\t\t\tsystem_tx\n\t\t\t\t\t.send(SystemMessage::ForceAbortion {\n\t\t\t\t\t\ttask_id,\n\t\t\t\t\t\ttask_work_table,","sourceCodeStart":507,"sourceCodeEnd":543,"githubUrl":"https://github.com/spacedriveapp/spacedrive/blob/6dfeccf2113039e35f2ce735f945e70dc3e4ea45/crates/task-system/src/system.rs#L507-L543","documentation":"SystemComm::resume_task (system.rs:509) spawns a detached task sending a ResumeTask message to the system loop; the .expect at system.rs:525 panics when the system channel is closed. It runs when TaskHandle::resume/TaskRemoteController::resume (task.rs:536) forwards the resume to the system. The ack oneshot is moved into the unsent message, so its drop cascades into the caller panic 'Worker failed to ack resume request' (task.rs:539).","triggerScenarios":"Calling handle.resume() after System::shutdown() completed or racing it; resuming a paused/queued task while the Tokio runtime is being dropped so the system loop's receiver no longer exists.","commonSituations":"Job-manager code resuming paused jobs during shutdown; UI resume actions pressed while the app is closing; tests resuming after the runtime began teardown.","solutions":["Do not resume during or after shutdown; gate resume behind your shutdown barrier and check handle.is_done() first","If the system is gone, re-dispatch the task on a new system instead of resuming (shutdown returns task objects via TaskStatus::Shutdown)","Order usage: resume while alive, shutdown last, drop runtime after","Library fix: has_shutdown guard in SystemComm plus SystemError propagation instead of .expect"],"exampleFix":"// before\nif let Ok(handle) = dispatcher.dispatch(task).await {\n    handle.pause().await?;\n    system.shutdown().await;\n    handle.resume().await?; // resume after shutdown -> system channel closed -> panic chain\n}\n\n// after\nif let Ok(handle) = dispatcher.dispatch(task).await {\n    handle.pause().await?;\n    handle.resume().await?; // resume while the system loop is alive\n    system.shutdown().await;\n}","handlingStrategy":"validation","validationCode":"// Resume only inside the live window.\nif !shutting_down.load(Ordering::Acquire) && !handle.is_done() {\n    handle.resume().await?;\n} else {\n    // system gone: recover the task object from TaskStatus::Shutdown and re-dispatch later\n}","typeGuard":null,"tryCatchPattern":"use futures_util::FutureExt; use std::panic::AssertUnwindSafe;\n// isolates the follow-up 'Worker failed to ack resume request' panic at the controller\nif AssertUnwindSafe(handle.resume()).catch_unwind().await.is_err() {\n    tracing::warn!(task = %handle.task_id(), \"resume lost: task system shutting down\");\n}","preventionTips":["Never resume during or after System::shutdown","Do not hold TaskRemoteController clones across shutdown expecting them to work","Model resume-after-restart as re-dispatch of the recovered task, not handle.resume()"],"tags":["rust","tokio","task-system","panic","channel","shutdown","use-after-shutdown"],"backgroundTag":null,"analyzedSha":"6dfeccf2113039e35f2ce735f945e70dc3e4ea45","analyzedAt":"2026-08-16T11:26:17.074Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}