nautechsystems/nautilus_trader · error

Cannot remove actor, {actor_id} not found

Error message

Cannot remove actor, {actor_id} not found

What it means

remove_actor was called with an ActorId not present in the trader's registry; the actor was never registered or has already been removed, so there is no component to dispose or deregister and the removal request is rejected.

Source

Thrown at crates/system/src/trader.rs:1318

        if !self.actor_ids.contains(actor_id) {
            anyhow::bail!("Cannot stop actor, {actor_id} not found");
        }
        stop_component(&actor_id.inner())
    }

    /// Removes the actor with the given `actor_id`.
    ///
    /// Will stop the actor first if it is currently running. Disposes the actor
    /// and removes it from the trader's tracking.
    ///
    /// # Errors
    ///
    /// Returns an error if the actor is not registered, or if disposal fails. A failed disposal
    /// keeps the actor registered and tracked, and leaves it `Faulted`; see [`Component::dispose`].
    /// Calling this again retires the actor.
    pub fn remove_actor(&mut self, actor_id: &ActorId) -> anyhow::Result<()> {
        if !self.actor_ids.contains(actor_id) {
            anyhow::bail!("Cannot remove actor, {actor_id} not found");
        }

        // Stop if running, then dispose
        let _ = stop_component(&actor_id.inner());
        self.retire_actor(*actor_id)?;

        log::info!("Removed actor {actor_id} from trader {}", self.trader_id);
        Ok(())
    }

    /// Starts the strategy with the given `strategy_id`.
    ///
    /// # Errors
    ///
    /// Returns an error if the strategy is not registered or cannot be started.
    pub fn start_strategy(&self, strategy_id: &StrategyId) -> anyhow::Result<()> {
        if !self.strategy_ids.contains(strategy_id) {
            anyhow::bail!("Cannot start strategy, {strategy_id} not found");

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Register the actor before removing it
  2. Verify the actor ID against the trader's registered actor IDs
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/system/src/trader.rs:1318 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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