nautechsystems/nautilus_trader · error

Failed during trader startup: {start_err}; failed to finaliz

Error message

Failed during trader startup: {start_err}; failed to finalize startup abort: {finalize_err}

What it means

Same compound-error path as its sibling: after a failed trader start, stopping the partial trader succeeded but finalize_stop() failed, so the message chains 'Failed during trader startup: {start_err}' with 'failed to finalize startup abort: {finalize_err}'.

Source

Thrown at crates/live/src/node/mod.rs:2331

        processed
    }

    async fn abort_after_trader_start_failure(
        &mut self,
        start_err: anyhow::Error,
    ) -> anyhow::Result<()> {
        log::info!("Trader startup failed, aborting startup");
        self.handle.set_shutting_down();
        let stop_result = self.kernel.stop_trader_after_start_failure();
        let finalize_result = self.finalize_stop().await;

        match (stop_result, finalize_result) {
            (Ok(()), Ok(())) => Err(start_err),
            (Err(stop_err), Ok(())) => anyhow::bail!(
                "Failed during trader startup: {start_err}; failed to stop partial trader start: \
                 {stop_err}"
            ),
            (Ok(()), Err(finalize_err)) => anyhow::bail!(
                "Failed during trader startup: {start_err}; failed to finalize startup abort: \
                 {finalize_err}"
            ),
            (Err(stop_err), Err(finalize_err)) => anyhow::bail!(
                "Failed during trader startup: {start_err}; failed to stop partial trader start: \
                 {stop_err}; failed to finalize startup abort: {finalize_err}"
            ),
        }
    }

    fn initiate_shutdown(&mut self) {
        #[cfg(feature = "plugin")]
        if let Err(e) = self.plugins.stop_controllers() {
            log::error!("Error stopping plug-in controllers: {e}");
        }
        self.kernel.stop_trader();
        let delay = self.kernel.delay_post_stop();
        log::info!("Awaiting residual events ({delay:?})...");

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Fix the original startup failure first (root cause)
  2. Examine why finalize_stop failed — each joined error names a failing finalization step
  3. Check for tasks that don't shut down or channels that were dropped early
  4. Add tracing around finalize_stop to capture the failing step
Defensive patterns

Strategy: try-catch

Try / catch

if let Err(e) = node.start().await {
    if e.to_string().contains("failed to finalize startup abort") {
        tracing::error!(error = %e, "startup abort finalization failed");
    }
    return Err(e);
}

Prevention

When it happens

Trigger: start or run_with_mode fails during trader startup; stop_trader_after_start_failure returns Ok but finalize_stop returns Err.

Common situations: Partial trader stops cleanly but final node shutdown steps (draining channels, kernel shutdown finalization) fail — e.g. background tasks not joining or channels already closed.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/2dc3206e0fd35334. Report an issue: GitHub.