nautechsystems/nautilus_trader · error · anyhow::Error
Failed to send order pending cancel event: {e}
Error message
Failed to send order pending cancel event: {e} What it means
When a pending-cancel state is emitted, the adapter sends an `OrderEventAny::PendingCancel` event over the unbounded mpsc `exec_sender`. Failure means the receiver has been dropped, so the pending-cancel transition cannot be recorded and the error is wrapped and propagated out of the helper.
Source
Thrown at crates/adapters/interactive_brokers/src/execution/core.rs:2429
let (trader_id, strategy_id) =
Self::get_required_order_actor_ids(order_id, trader_id_map, strategy_id_map)?;
let event = OrderPendingCancel::new(
trader_id,
strategy_id,
instrument_id,
client_order_id,
Some(account_id),
UUID4::new(),
ts_init,
ts_init,
false,
Some(venue_order_id),
);
exec_sender
.send(ExecutionEvent::Order(OrderEventAny::PendingCancel(event)))
.map_err(|e| anyhow::anyhow!("Failed to send order pending cancel event: {e}"))?;
Ok(())
}
}
View on GitHub (pinned to 18893faf8b)
Solutions
- Keep the execution event loop alive until the adapter is disconnected and all in-flight cancels settle.
- Confirm the exec channel receiver is correctly registered before issuing cancels.
- Treat the failure as non-fatal at teardown by logging a warning instead of aborting.
Example fix
// before
exec_sender
.send(ExecutionEvent::Order(OrderEventAny::PendingCancel(event)))
.map_err(|e| anyhow::anyhow!("Failed to send order pending cancel event: {e}"))?;
// after
if let Err(e) = exec_sender.send(ExecutionEvent::Order(OrderEventAny::PendingCancel(event))) {
log::warn!("pending cancel event dropped (receiver closed): {e}");
} Defensive patterns
Strategy: try-catch
Try / catch
if let Err(e) = client.cancel_order(&cmd).await {
if e.to_string().contains("Failed to send order pending cancel event") {
log::warn!("pending cancel event lost (receiver closed): {e}");
} else {
return Err(e);
}
} Prevention
- Keep the execution event loop running until all in-flight cancels reach a terminal state.
- Disconnect the adapter only after the engine and its event receiver are still alive to consume final events.
- Monitor shutdown logs for late PendingCancel/Denied events to tune teardown ordering.
When it happens
Trigger: The adapter emits PendingCancel (e.g. a cancel request was accepted/queued at IB) while the execution event receiver is closed — during node shutdown or if the channel wiring was torn down early.
Common situations: Cancel in flight at shutdown; IB acknowledging a cancel after the event loop stopped; tests/tools dropping the receiver before replaying queued events.
Related errors
- Failed to send order denied event: {e}
- Failed to send order modify rejected event: {e}
- Failed to send order cancel rejected event: {e}
- task slot is already occupied
- failed to finish Binance Futures data command tasks: {e}
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/13f59c02a297452e.
Report an issue: GitHub.