nautechsystems/nautilus_trader · error

{startup_err}; failed to finalize startup abort: {finalize_e

Error message

{startup_err}; failed to finalize startup abort: {finalize_err}

What it means

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.

Source

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

            }
        }
    }

    async fn abort_startup(&mut self, reason: &str) -> anyhow::Result<()> {
        log::info!("{reason}, aborting startup");
        self.handle.set_shutting_down();
        self.finalize_stop().await
    }

    async fn abort_startup_with_error(
        &mut self,
        reason: &str,
        startup_err: anyhow::Error,
    ) -> anyhow::Result<()> {
        match self.abort_startup(reason).await {
            Ok(()) => Err(startup_err),
            Err(finalize_err) => {
                anyhow::bail!("{startup_err}; failed to finalize startup abort: {finalize_err}")
            }
        }
    }

    async fn abort_started_trader(
        &mut self,
        reason: &str,
        mut receivers: Option<&mut RunnerReceivers<'_>>,
    ) -> anyhow::Result<()> {
        log::info!("{reason}, aborting startup");
        self.handle.set_shutting_down();

        #[cfg(feature = "plugin")]
        let controller_stop_result = self.plugins.stop_controllers();
        #[cfg(not(feature = "plugin"))]
        let controller_stop_result: anyhow::Result<()> = Ok(());

        let trader_stop_result = self.kernel.stop_trader_after_start_failure();

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Read the FIRST error in the message — it is the original startup failure and the root cause
  2. Fix the underlying startup failure (config, adapters, connections)
  3. Investigate the 'failed to finalize startup abort' portion separately: enable logging around abort_startup to see why cleanup failed
  4. Retry node startup after fixing; if finalize errors persist, check for leaked resources or double-stop calls

Example fix

// before: ignoring the compound cause and retrying blindly
node.start().await?;
// after: log both parts of the compound error before acting
if let Err(e) = node.start().await {
    tracing::error!(error = %e, "node startup failed (message includes any abort/finalize errors)");
    return Err(e);
}
Defensive patterns

Strategy: try-catch

Try / catch

match node.start().await {
    Ok(()) => {},
    Err(e) => {
        // message may contain startup error + finalize error; log full chain
        tracing::error!(error = %e, "startup failed; check for 'failed to finalize startup abort' suffix");
        return Err(e);
    }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

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/e63db405ce14d46e. Report an issue: GitHub.