{"record":{"id":"e63db405ce14d46e","repo":"nautechsystems/nautilus_trader","slug":"startup-err-failed-to-finalize-startup-abort","errorCode":null,"errorMessage":"{startup_err}; failed to finalize startup abort: {finalize_err}","messagePattern":"(.+?); failed to finalize startup abort: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/live/src/node/mod.rs","lineNumber":2198,"sourceCode":"            }\n        }\n    }\n\n    async fn abort_startup(&mut self, reason: &str) -> anyhow::Result<()> {\n        log::info!(\"{reason}, aborting startup\");\n        self.handle.set_shutting_down();\n        self.finalize_stop().await\n    }\n\n    async fn abort_startup_with_error(\n        &mut self,\n        reason: &str,\n        startup_err: anyhow::Error,\n    ) -> anyhow::Result<()> {\n        match self.abort_startup(reason).await {\n            Ok(()) => Err(startup_err),\n            Err(finalize_err) => {\n                anyhow::bail!(\"{startup_err}; failed to finalize startup abort: {finalize_err}\")\n            }\n        }\n    }\n\n    async fn abort_started_trader(\n        &mut self,\n        reason: &str,\n        mut receivers: Option<&mut RunnerReceivers<'_>>,\n    ) -> anyhow::Result<()> {\n        log::info!(\"{reason}, aborting startup\");\n        self.handle.set_shutting_down();\n\n        #[cfg(feature = \"plugin\")]\n        let controller_stop_result = self.plugins.stop_controllers();\n        #[cfg(not(feature = \"plugin\"))]\n        let controller_stop_result: anyhow::Result<()> = Ok(());\n\n        let trader_stop_result = self.kernel.stop_trader_after_start_failure();","sourceCodeStart":2180,"sourceCodeEnd":2216,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/live/src/node/mod.rs#L2180-L2216","documentation":"This error occurs when a live node's startup failed and the library then attempted a graceful abort (abort_startup) of the not-yet-started trader, but that abort itself also failed. Both the original startup error and the abort/finalize error are concatenated into one anyhow error so no diagnostic context is lost.","triggerScenarios":"Calling start, run_with_mode, or finish_startup_replay when the trader startup fails (startup_err) AND abort_startup subsequently returns Err (finalize_err) — e.g. kernel shutdown or channel draining fails during the cleanup path.","commonSituations":"A misconfigured adapter or connection failure causes startup to fail, and a second problem (already-shut-down kernel, poisoned lock, background task panic) prevents clean rollback; the developer sees two stacked errors and must fix the root cause (the first) plus investigate why cleanup failed.","solutions":["Read the FIRST error in the message — it is the original startup failure and the root cause","Fix the underlying startup failure (config, adapters, connections)","Investigate the 'failed to finalize startup abort' portion separately: enable logging around abort_startup to see why cleanup failed","Retry node startup after fixing; if finalize errors persist, check for leaked resources or double-stop calls"],"exampleFix":"// before: ignoring the compound cause and retrying blindly\nnode.start().await?;\n// after: log both parts of the compound error before acting\nif let Err(e) = node.start().await {\n    tracing::error!(error = %e, \"node startup failed (message includes any abort/finalize errors)\");\n    return Err(e);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match node.start().await {\n    Ok(()) => {},\n    Err(e) => {\n        // message may contain startup error + finalize error; log full chain\n        tracing::error!(error = %e, \"startup failed; check for 'failed to finalize startup abort' suffix\");\n        return Err(e);\n    }\n}","preventionTips":["Validate all adapter/config setup before starting the node","Ensure the node can be cleanly aborted (no background holders of kernel locks)","Log both segments of compound errors instead of only the first line"],"tags":["rust","startup","live-node","error-chaining"],"backgroundTag":"internal-invariant-violation","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}