nautechsystems/nautilus_trader · error · anyhow::Error

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

Error message

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

What it means

Mirroring the data client, the dYdX execution client collects errors from its session tasks during shutdown; finish_shutdown drains shutdown_errors and bails with all messages joined by '; '. It reports any task that failed to finish cleanly when stopping the execution engine.

Source

Thrown at crates/adapters/dydx/src/execution/mod.rs:991

        Ok(())
    }

    async fn finish_shutdown(&mut self) -> anyhow::Result<()> {
        if let Err(e) = self
            .ws_client
            .disconnect()
            .await
            .context("failed to disconnect dYdX websocket")
        {
            self.shutdown_errors.push(e.to_string());
        }

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

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

    async fn teardown_partial_connect(&mut self) -> anyhow::Result<()> {
        self.begin_pending_shutdown();
        self.session_tasks.begin_shutdown();
        self.ws_client.begin_shutdown();
        let shutdown_result = self.finish_shutdown().await;
        self.core.set_disconnected();
        shutdown_result
    }

    fn send_modify_rejected(
        &self,
        strategy_id: StrategyId,
        instrument_id: InstrumentId,
        client_order_id: ClientOrderId,

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Inspect the joined error strings to find the failing task's root cause
  2. Check connectivity/credentials if the WebSocket task is the failing one
  3. Log and handle shutdown errors gracefully; retry disconnect if the transport was already broken
Defensive patterns

Strategy: try-catch

Try / catch

match client.disconnect().await {
    Ok(()) => {},
    Err(e) => {
        for msg in e.to_string().split("; ") {
            log::warn!("execution shutdown task error: {msg}");
        }
    }
}

Prevention

When it happens

Trigger: Calling finish_shutdown (via prepare_task_groups or teardown_partial_connect) when any session task (WebSocket handler, order/stream tasks) ended with an Err or panic during shutdown.

Common situations: Live WebSocket failing during client stop; order submission task erroring concurrently with shutdown; forced disconnects from the exchange mid-teardown.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


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