{"record":{"id":"e414c9bf84dad5d4","repo":"nautechsystems/nautilus_trader","slug":"failed-to-send-command-to-dataset-dataset-e","errorCode":null,"errorMessage":"Failed to send command to dataset {dataset}: {e}","messagePattern":"Failed to send command to dataset (.+?): (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/databento/src/data.rs","lineNumber":1446,"sourceCode":"        .map(dbn::Schema::as_str)\n        .collect::<Vec<_>>()\n        .join(\", \");\n    anyhow::bail!(\n        \"Invalid `{SCHEMA_PARAM}` '{}'. Must be one of: {allowed}\",\n        schema.as_str()\n    );\n}\n\nfn send_subscription_commands(\n    tx: &tokio::sync::mpsc::UnboundedSender<HandlerCommand>,\n    dataset: &str,\n    price_precision: Option<(Symbol, u8)>,\n    subscription: Subscription,\n    start_after_subscribe: bool,\n) -> anyhow::Result<()> {\n    if let Some((symbol, precision)) = price_precision {\n        tx.send(HandlerCommand::SetPricePrecision(symbol, precision))\n            .map_err(|e| anyhow::anyhow!(\"Failed to send command to dataset {dataset}: {e}\"))?;\n    }\n\n    tx.send(HandlerCommand::Subscribe(subscription))\n        .map_err(|e| anyhow::anyhow!(\"Failed to send command to dataset {dataset}: {e}\"))?;\n\n    if start_after_subscribe {\n        tx.send(HandlerCommand::Start)\n            .map_err(|e| anyhow::anyhow!(\"Failed to send command to dataset {dataset}: {e}\"))?;\n    }\n\n    Ok(())\n}\n\n#[cfg(test)]\nmod tests {\n    use std::path::PathBuf;\n\n    use nautilus_common::live::runner::replace_data_event_sender;","sourceCodeStart":1428,"sourceCodeEnd":1464,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/databento/src/data.rs#L1428-L1464","documentation":"This error is raised when sending a HandlerCommand::SetPricePrecision to the databento subscription command channel fails. The channel to the handler command loop is closed or full, so the precision update cannot be delivered before subscribing. It wraps the underlying mpsc send error and identifies the target dataset.","triggerScenarios":"Calling send_subscription_to_dataset (via send_subscription_commands) with Some(price_precision) while the command channel receiver has been dropped, or when the bounded channel buffer is full at send time.","commonSituations":"Subscribing with a price precision after the data handler's command loop has already shut down (client disconnect/reconnect race); heavy subscribe bursts overflowing the bounded command channel; tests simulating closed channels.","solutions":["Verify the client's command-handling task is still running before calling subscribe APIs","Retry the subscription after re-establishing the client connection","Log and surface the dataset name and underlying send error for diagnosis","Check for races where the subscription stream is closed concurrently with subscribe calls"],"exampleFix":"// before\nclient.subscribe(...).map_err(|e| anyhow!(\"subscribe failed: {e}\"))?;\n// after\nif !client.is_connected() { client.reconnect().await?; }\nclient.subscribe(...).map_err(|e| anyhow!(\"subscribe failed: {e}\"))?;","handlingStrategy":"validation","validationCode":"// Rust\nif tx.is_closed() { anyhow::bail!(\"command channel closed for {dataset}\"); }","typeGuard":null,"tryCatchPattern":"// Rust\nif let Err(e) = send_subscription_to_dataset(...).await {\n    error!(\"{e:#}\");\n}\n","preventionTips":["Check channel state before sends","Reconnect before retrying","Avoid burst subscribes","Log dataset context"],"tags":["rust","anyhow","channel","subscription"],"backgroundTag":"broken-pipe","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"}