nautechsystems/nautilus_trader · error
cannot cancel Lighter order {}: venue order_id not yet known
Error message
cannot cancel Lighter order {}: venue order_id not yet known (await OrderAccepted before issuing cancel) What it means
Lighter cancels target a venue order_id, but neither the command nor the adapter's dispatch map (populated on the first OrderStatusReport/OrderAccepted for the client_order_id) knows it. The order is likely not yet accepted by the venue, so there is nothing addressable to cancel.
Source
Thrown at crates/adapters/lighter/src/execution.rs:1794
let market_index = self
.registry
.market_index(&cmd.instrument_id)
.ok_or_else(|| {
anyhow::anyhow!(
"no Lighter market_index registered for instrument {}",
cmd.instrument_id,
)
})?;
self.core.cache().try_order(&cmd.client_order_id)?;
// Lighter cancel_order targets a single order by venue order_id.
// The map is populated on the first OrderStatusReport for the cloid.
let voi = cmd
.venue_order_id
.or_else(|| self.dispatch.lookup_venue_order_id(&cmd.client_order_id))
.ok_or_else(|| {
anyhow::anyhow!(
"cannot cancel Lighter order {}: venue order_id not yet known \
(await OrderAccepted before issuing cancel)",
cmd.client_order_id,
)
})?;
let venue_index: i64 = voi
.as_str()
.parse()
.with_context(|| format!("Lighter venue_order_id `{voi}` is not an integer index"))?;
Ok(CancelOrderPlan {
client_order_id: cmd.client_order_id,
strategy_id: cmd.strategy_id,
instrument_id: cmd.instrument_id,
venue_order_id: Some(voi),
market_index,
venue_index,View on GitHub (pinned to 18893faf8b)
Solutions
- Wait for the OrderAccepted event (or a venue_order_id) before issuing the cancel.
- Retry the cancel with backoff; the venue order_id may arrive momentarily via WS.
- Verify the client_order_id is correct — a typo'd id never maps to a venue order.
- Handle the rejected-order case: if no report ever arrives, the order may have been rejected.
Example fix
// before execution.cancel_order(CancelOrder::new(instrument_id, cloid, None))?; // immediately after submit // after wait_for_event(Event::OrderAccepted(cloid)).await; execution.cancel_order(CancelOrder::new(instrument_id, cloid, None))?;
Defensive patterns
Strategy: retry
Validate before calling
// Rust
anyhow::ensure!(
cmd.venue_order_id.is_some() || dispatch_has_venue_id(&cmd.client_order_id),
"await OrderAccepted before cancelling {}",
cmd.client_order_id
); Try / catch
match adapter.cancel_order(cmd.clone()) {
Err(e) if e.to_string().contains("venue order_id not yet known") => {
wait_for_order_accepted(cmd.client_order_id, Duration::from_secs(5)).await?;
adapter.cancel_order(cmd)
}
other => other,
} Prevention
- Wait for OrderAccepted events before canceling freshly submitted orders
- Implement cancel retries with backoff in flatten logic
- Track order lifecycle state per client_order_id in the strategy
When it happens
Trigger: dispatch_signed_cancel_order or batch_cancel_orders where cmd.venue_order_id is None AND dispatch.lookup_venue_order_id(&cmd.client_order_id) is None — cancel issued before any status report arrived for the order.
Common situations: Flatten/cancel-all logic racing a just-submitted order; cancel sent immediately after submit without awaiting OrderAccepted; WS event latency delaying the first status report; order actually rejected so no venue id ever arrives.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- Order denied: invalid status for {}, expected INITIALIZED
- no Lighter market_index registered for instrument {}
- {FAILED}: {e}
- Cancel algo order failed: code={}, msg={}
- No healthy transport clients available
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/50054686e4bef2d5.
Report an issue: GitHub.