{"record":{"id":"a14b9ce1a10a4be0","repo":"nautechsystems/nautilus_trader","slug":"already-running","errorCode":null,"errorMessage":"Already running","messagePattern":"Already running","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/live/src/node/mod.rs","lineNumber":916,"sourceCode":"    /// # Errors\n    ///\n    /// Returns an error if the node fails to start or encounters a runtime error.\n    pub async fn run(&mut self) -> anyhow::Result<()> {\n        self.run_with_mode(NodeRunMode::Owned).await\n    }\n\n    /// Run the live node under the given mode.\n    ///\n    /// [`NodeRunMode::Hosted`] leaves signal handling to the host application. Every other\n    /// responsibility, including maintenance, reconciliation, external ingress, and the shutdown\n    /// sequence, is identical across modes so that hosted and owned nodes cannot diverge.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the node fails to start or encounters a runtime error.\n    pub async fn run_with_mode(&mut self, mode: NodeRunMode) -> anyhow::Result<()> {\n        if self.state().is_running() {\n            anyhow::bail!(\"Already running\");\n        }\n\n        if self.runner.is_none() {\n            anyhow::bail!(\"Runner already consumed - run() called twice\");\n        }\n\n        self.prepare_cache().await?;\n\n        let Some(runner) = self.runner.take() else {\n            anyhow::bail!(\"Runner already consumed - run() called twice\");\n        };\n        runner.bind_senders();\n\n        let AsyncRunnerChannels {\n            mut time_evt_rx,\n            mut system_evt_rx,\n            mut system_cmd_rx,\n            mut exec_evt_rx,","sourceCodeStart":898,"sourceCodeEnd":934,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/2114cf6f761429e0adb5ca9596fcd7b895b16011/crates/live/src/node/mod.rs#L898-L934","documentation":"LiveNode::run_with_mode (crates/live/src/node/mod.rs:914) drives the full node lifecycle and is single-shot: it checks state().is_running() and bails with \"Already running\" if the node is currently running. A companion check rejects a second run after the runner was consumed, so a node instance can only ever be run once to completion.","triggerScenarios":"Calling node.run() or node.run_with_mode(mode) a second time while the first run is still active; hosted integrations calling run_with_mode(NodeRunMode::Hosted) while an owned run() is in flight on the same node; retry wrappers re-invoking run() after an error while the node is still up.","commonSituations":"Error-handling retry loops around node.run(); re-running a notebook cell that calls run() on the same node object; hosting frameworks starting the node from two places; trying to restart a node after shutdown instead of building a new one.","solutions":["Call run()/run_with_mode() exactly once per node instance; build and configure a fresh node for another session.","Guard the call with the node's state (e.g. skip when it reports running).","In hosted mode, ensure only the host drives run_with_mode and application code never calls run() itself.","Distinguish this from the follow-up error \"Runner already consumed - run() called twice\": after a completed run the node is not reusable at all."],"exampleFix":"// before\nnode.run().await?; // called again elsewhere -> \"Already running\"\n\n// after\nif !node.state().is_running() {\n    node.run().await?;\n} else {\n    log::warn!(\"node already running, skipping duplicate run\");\n}","handlingStrategy":"validation","validationCode":"if !node.state().is_running() {\n    node.run_with_mode(mode).await?;\n} else {\n    log::warn!(\"node already running; skipping duplicate run\");\n}","typeGuard":null,"tryCatchPattern":"match node.run().await {\n    Ok(()) => {}\n    Err(e) if e.to_string() == \"Already running\" => {\n        log::warn!(\"run() called on an active node; ignoring\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Call run() exactly once per node instance; construct a new node for the next session.","Do not wrap node.run() in blind retry loops.","In hosted mode let only the host call run_with_mode."],"tags":["live-node","lifecycle","double-start"],"backgroundTag":"already-running-guard","analyzedSha":"2114cf6f761429e0adb5ca9596fcd7b895b16011","analyzedAt":"2026-08-21T11:28:30.864Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}