{"record":{"id":"e045a1f3b2356a0d","repo":"nautechsystems/nautilus_trader","slug":"client-never-started","errorCode":null,"errorMessage":"Client never started","messagePattern":"Client never started","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/databento/src/live.rs","lineNumber":297,"sourceCode":"            self.bars_timestamp_on_close,\n            self.reconnect_timeout_mins,\n        );\n\n        self.send_command(HandlerCommand::Start)?;\n        self.is_running = true;\n\n        Ok((feed_handler, msg_rx))\n    }\n\n    /// Closes the live client.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the client was never started, is already closed, or cannot send\n    /// the close command to the feed handler.\n    pub fn close(&mut self) -> anyhow::Result<()> {\n        if !self.is_running {\n            anyhow::bail!(\"Client never started\");\n        }\n\n        if self.is_closed {\n            anyhow::bail!(\"Client already closed\");\n        }\n\n        log::debug!(\"Closing client\");\n\n        if !self.cmd_tx.is_closed() {\n            self.send_command(HandlerCommand::Close)?;\n        }\n\n        self.is_running = false;\n        self.is_closed = true;\n\n        Ok(())\n    }\n","sourceCodeStart":279,"sourceCodeEnd":315,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/databento/src/live.rs#L279-L315","documentation":"`close` requires the client to have been started (`is_running == true`). Calling close on a client that was constructed but never started is an invalid state transition, so it bails with this error rather than performing a no-op teardown.","triggerScenarios":"Calling `close` (or `py_close`) on a DatabentoLive client before `start` was ever called, or after a failed start left `is_running` false.","commonSituations":"Error-path cleanup code that unconditionally closes all clients, including ones that never started; shutdown handlers iterating a registry of clients regardless of state; calling close after a start that itself errored.","solutions":["Only call close after a successful `start`; track client state before cleanup.","Make cleanup idempotent: skip close when the client was never started or is not running.","If start failed, drop the client instead of closing it.","Guard cleanup loops with a started/running check per client."],"exampleFix":"// before\nlet mut client = DatabentoLive::new(...)?;\nclient.close()?; // error: never started\n// after\nlet mut client = DatabentoLive::new(...)?;\nclient.start().await?;\n// ... later ...\nclient.close()?;","handlingStrategy":"try-catch","validationCode":"// Only close clients that were started\nif client.is_running() {\n    client.close()?;\n}","typeGuard":null,"tryCatchPattern":"// Tolerate never-started in bulk cleanup\nfor client in &mut clients {\n    if client.is_running() {\n        if let Err(e) = client.close() {\n            log::warn!(\"close failed: {e}\");\n        }\n    }\n}","preventionTips":["Track a started flag per client in your session/registry code","On start failure, drop the client rather than calling close","Make teardown loops conditional on running state"],"tags":["databento","lifecycle","state-transition","live-client"],"backgroundTag":"invalid-state-transition","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}