nautechsystems/nautilus_trader · error · anyhow::Error
Failed to send command to dataset {dataset}: {e}
Error message
Failed to send command to dataset {dataset}: {e} What it means
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.
Source
Thrown at crates/adapters/databento/src/data.rs:1446
.map(dbn::Schema::as_str)
.collect::<Vec<_>>()
.join(", ");
anyhow::bail!(
"Invalid `{SCHEMA_PARAM}` '{}'. Must be one of: {allowed}",
schema.as_str()
);
}
fn send_subscription_commands(
tx: &tokio::sync::mpsc::UnboundedSender<HandlerCommand>,
dataset: &str,
price_precision: Option<(Symbol, u8)>,
subscription: Subscription,
start_after_subscribe: bool,
) -> anyhow::Result<()> {
if let Some((symbol, precision)) = price_precision {
tx.send(HandlerCommand::SetPricePrecision(symbol, precision))
.map_err(|e| anyhow::anyhow!("Failed to send command to dataset {dataset}: {e}"))?;
}
tx.send(HandlerCommand::Subscribe(subscription))
.map_err(|e| anyhow::anyhow!("Failed to send command to dataset {dataset}: {e}"))?;
if start_after_subscribe {
tx.send(HandlerCommand::Start)
.map_err(|e| anyhow::anyhow!("Failed to send command to dataset {dataset}: {e}"))?;
}
Ok(())
}
#[cfg(test)]
mod tests {
use std::path::PathBuf;
use nautilus_common::live::runner::replace_data_event_sender;View on GitHub (pinned to 18893faf8b)
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
Example fix
// before
client.subscribe(...).map_err(|e| anyhow!("subscribe failed: {e}"))?;
// after
if !client.is_connected() { client.reconnect().await?; }
client.subscribe(...).map_err(|e| anyhow!("subscribe failed: {e}"))?; Defensive patterns
Strategy: validation
Validate before calling
// Rust
if tx.is_closed() { anyhow::bail!("command channel closed for {dataset}"); } Try / catch
// Rust
if let Err(e) = send_subscription_to_dataset(...).await {
error!("{e:#}");
}
Prevention
- Check channel state before sends
- Reconnect before retrying
- Avoid burst subscribes
- Log dataset context
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Binance liquidation custom data requires BINANCE venue instr
- Binance Futures supports L1_MBP and L2_MBP order book subscr
- Binance Spot supports L1_MBP and L2_MBP order book subscript
- Unknown execution event marker {event}
- Command receiver already taken
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/e414c9bf84dad5d4.
Report an issue: GitHub.