nautechsystems/nautilus_trader · error

std::mem::take(&mut self.shutdown_errors).join("; ")

Error message

std::mem::take(&mut self.shutdown_errors).join("; ")

What it means

Identical pattern to the data client: AX execution client's `teardown_partial_connect` drains self.shutdown_errors and bails with them joined by ';'. It indicates the execution connect failed partway and cleanup steps (e.g. awaiting pending results) also reported errors.

Source

Thrown at crates/adapters/architect_ax/src/execution.rs:452

        if let Err(e) = self.ws_orders.close().await {
            self.shutdown_errors
                .push(format!("AX orders WebSocket shutdown failed: {e}"));
        }

        let (session_result, pending_result) =
            tokio::join!(self.await_session_tasks(), self.await_pending_tasks());
        self.core.set_disconnected();

        if let Err(e) = session_result {
            self.shutdown_errors.push(e.to_string());
        }

        if let Err(e) = pending_result {
            self.shutdown_errors.push(e.to_string());
        }

        if !self.shutdown_errors.is_empty() {
            anyhow::bail!(std::mem::take(&mut self.shutdown_errors).join("; "));
        }
        Ok(())
    }

    /// Polls the cache until the account is registered or timeout is reached.
    async fn await_account_registered(&self, timeout_secs: f64) -> anyhow::Result<()> {
        let account_id = self.core.account_id;

        if self.core.cache().account(&account_id).is_some() {
            log::info!("Account {account_id} registered");
            return Ok(());
        }

        let start = Instant::now();
        let timeout = Duration::from_secs_f64(timeout_secs);
        let interval = Duration::from_millis(10);

        loop {

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Parse the joined messages to identify the root failure versus secondary teardown errors
  2. Fix the underlying connect problem (credentials, gateway URL, network) and reconnect
  3. Check whether the pending-result error indicates an unresponsive gateway needing a longer timeout
Defensive patterns

Strategy: retry

Validate before calling

// Validate credentials and gateway URL before constructing the execution client
if api_key.is_empty() || gateway_url.is_empty() { return Err("missing AX exec config"); }

Try / catch

match exec_client.connect().await {
    Ok(()) => {},
    Err(e) => { log::error!("AX exec connect failed: {e}"); /* fix root cause, then reconnect */ }
}

Prevention

When it happens

Trigger: connect() on AXExecutionClient partially succeeds then fails (auth rejected, account lookup fails), and teardown tasks/pending results return errors.

Common situations: Invalid API credentials; AX execution gateway down; timeout races during client startup.

Understand the failure class

Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.

Related errors


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