{"record":{"id":"a8fd95a507338691","repo":"nautechsystems/nautilus_trader","slug":"commandsenderror-details","errorCode":null,"errorMessage":"CommandSendError: {details}","messagePattern":"CommandSendError: (.+?)","errorType":"exception","errorClass":"CommandSendError","httpStatus":null,"severity":"error","filePath":"crates/adapters/databento/src/live.rs","lineNumber":318,"sourceCode":"        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\n    fn send_command(&self, cmd: HandlerCommand) -> anyhow::Result<()> {\n        self.cmd_tx.send(cmd).map_err(|e| {\n            anyhow::Error::new(CommandSendError {\n                details: e.to_string(),\n            })\n        })\n    }\n}\n\n#[cfg(any(test, feature = \"python\"))]\npub(crate) fn is_command_send_error(error: &anyhow::Error) -> bool {\n    error.is::<CommandSendError>()\n}\n\n#[derive(Debug)]\nstruct CommandSendError {\n    details: String,\n}\n\nimpl Display for CommandSendError {\n    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {","sourceCodeStart":300,"sourceCodeEnd":336,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/databento/src/live.rs#L300-L336","documentation":"This error is raised when the Databento live data client fails to send a HandlerCommand to its internal command channel (cmd_tx.send(cmd)). The channel send only fails if the receiver half has been dropped — meaning the command-processing loop inside the client is no longer running, so the client cannot accept any further commands (subscribe/unsubscribe etc.).","triggerScenarios":"Calling send_command (via any public command path on the Databento live client) after the command receiver task has exited — e.g. the client's internal loop was stopped, the runtime is shutting down, or the client was disconnected.","commonSituations":"Issuing subscribe/unsubscribe commands after stopping the Databento live client; shutdown race where the node tears down while data handlers still send commands; a panic or early exit in the client's command loop.","solutions":["Verify the Databento live client is still running/connected before sending commands","Check for premature termination of the client's command-processing loop (panics, early returns)","Guard shutdown ordering: stop data handlers before dropping the client's command receiver","Inspect logs for runtime shutdown occurring while commands were in flight","Recreate the client if its internal loop has terminated"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Guard: only send commands while the client loop is running\nif !client.is_running() {\n    return Err(anyhow!(\"Databento client stopped; cannot send command\"));\n}","typeGuard":"fn is_command_send_failure(err: &anyhow::Error) -> bool {\n    err.to_string().starts_with(\"CommandSendError:\")\n}","tryCatchPattern":"if let Err(e) = client.send_command(cmd) {\n    if is_command_send_failure(&e) {\n        log::error!(\"Databento command loop gone; dropping client: {e}\");\n        // stop using this client; recreate if needed\n    } else { return Err(e); }\n}","preventionTips":["Stop data handlers before tearing down the client's command receiver","Check client liveness before issuing subscribe/unsubscribe commands","Fix any panics/early exits in the client's command loop","Ensure runtime shutdown ordering doesn't drop the receiver while handlers run"],"tags":["databento","channel","shutdown","live-data"],"backgroundTag":"broken-pipe","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}