{"record":{"id":"168b7877a0a4debf","repo":"nautechsystems/nautilus_trader","slug":"failed-to-stop-trader-components-stop-err-fail","errorCode":null,"errorMessage":"Failed to stop trader components: {stop_err}; failed to complete trader stop: {transition_err}","messagePattern":"Failed to stop trader components: (.+?); failed to complete trader stop: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/system/src/trader.rs","lineNumber":1121,"sourceCode":"    /// Stops a partially started trader without deferring managed strategy shutdown.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the trader transition or any component stop fails. All registered\n    /// components still receive a stop attempt before the error is returned.\n    pub fn stop_after_start_failure(&mut self) -> anyhow::Result<()> {\n        self.transition_state(ComponentTrigger::Stop)?;\n\n        let stop_result = self.stop_components_after_start_failure();\n        let clock = self.clock_factory.clock();\n        self.ts_stopped = Some(clock.borrow().timestamp_ns());\n        let transition_result = self.transition_state(ComponentTrigger::StopCompleted);\n\n        match (stop_result, transition_result) {\n            (Ok(()), Ok(())) => Ok(()),\n            (Err(stop_err), Ok(())) => Err(stop_err),\n            (Ok(()), Err(transition_err)) => Err(transition_err),\n            (Err(stop_err), Err(transition_err)) => anyhow::bail!(\n                \"Failed to stop trader components: {stop_err}; failed to complete trader stop: \\\n                 {transition_err}\"\n            ),\n        }\n    }\n\n    fn stop_components_after_start_failure(&mut self) -> anyhow::Result<()> {\n        let mut errors = Vec::new();\n\n        for actor_id in &self.actor_ids {\n            log::debug!(\"Stopping actor {actor_id} after startup failure\");\n            if let Err(e) = Self::stop_component_if_active(actor_id.inner()) {\n                errors.push(format!(\"actor {actor_id}: {e:#}\"));\n            }\n        }\n\n        for exec_algorithm_id in self.exec_algorithm_ids.clone() {\n            log::debug!(\"Stopping execution algorithm {exec_algorithm_id} after startup failure\");","sourceCodeStart":1103,"sourceCodeEnd":1139,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/system/src/trader.rs#L1103-L1139","documentation":"Composite failure in stop_after_start_failure: stopping the trader's components failed and the final trader stop transition also failed; all components still receive a stop attempt, but both errors are surfaced.","triggerScenarios":"Thrown at crates/system/src/trader.rs:1121 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the component stop errors and the transition error independently","Force-dispose components manually if the stop transition failed"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}