nautechsystems/nautilus_trader · error · DydxError::Nautilus
error.to_string()
Error message
error.to_string()
What it means
After exhausting retry attempts, `broadcast_with_retry` converts the retry manager's `RetryError` into a `DydxError::Nautilus` using the error's string form. This is the terminal 'broadcast failed after all retries' error: every attempt at the dYdX broadcast operation failed (e.g. sequence mismatches, HTTP/submit failures) and the retry policy gave up.
Source
Thrown at crates/adapters/dydx/src/execution/broadcaster.rs:247
if e.is_sequence_mismatch() {
// Set flag so next attempt will resync
needs_resync_for_retry.store(true, Ordering::SeqCst);
log::warn!("Sequence mismatch detected, will resync and retry");
true
} else if e.is_transient() {
// Also resync on transient errors (timeout, unavailable).
// Without this, each retry allocates a NEW sequence, causing drift
// (e.g., timeout → alloc 314, timeout → alloc 315, then sequence mismatch).
needs_resync_for_retry.store(true, Ordering::SeqCst);
log::warn!("Transient error detected, will resync and retry: {e}");
true
} else {
false
}
};
let create_error =
|error: RetryError| DydxError::Nautilus(anyhow::anyhow!(error.to_string()));
// Permit is held throughout retry loop, released when _permit drops
let result = self
.retry_manager
.invocation(operation_name, operation, should_retry, create_error)
.execute()
.await;
if let Err(ref e) = result
&& (e.is_transient() || e.is_sequence_mismatch())
{
log::error!("Broadcast exhausted retries: operation={operation_name}, error={e}");
}
result
}
/// Broadcasts a short-term order transaction without sequence management.View on GitHub (pinned to 18893faf8b)
Solutions
- Read the inner `error.to_string()` to identify the root cause (sequence mismatch vs API error)
- On sequence errors, resync the account sequence (fresh account/query) before broadcasting again
- Check dYdX node/indexer connectivity and RPC endpoint health
- Validate the transaction contents (gas, fees, memo) if the node rejected it on every attempt
- Increase retry budget/backoff for transient network conditions if attempts were exhausted too fast
Example fix
// before
let tx_hash = broadcaster.broadcast_with_retry("place_order", op).await?; // fails with RetryError
// after
match broadcaster.broadcast_with_retry("place_order", op).await {
Ok(h) => Ok(h),
Err(e) if e.to_string().contains("sequence mismatch") => {
broadcaster.resync_sequence().await?;
broadcaster.broadcast_with_retry("place_order", op).await
}
Err(e) => Err(e),
} Defensive patterns
Strategy: retry
Validate before calling
// Check sequence state freshness before broadcasting broadcaster.ensure_sequence_fresh().await?;
Type guard
fn is_sequence_mismatch(e: &DydxError) -> bool { e.to_string().contains("sequence mismatch") } Try / catch
match broadcaster.broadcast_with_retry(op_name, op).await {
Ok(h) => Ok(h),
Err(e) if is_sequence_mismatch(&e) => { broadcaster.resync_sequence().await?; broadcaster.broadcast_with_retry(op_name, op).await }
Err(e) => Err(e),
} Prevention
- Keep account sequence state in sync across restarts
- Use exponential backoff and adequate retry budgets
- Monitor node/indexer health before and during trading
- Log the inner RetryError string for root-cause triage
When it happens
Trigger: Calling `broadcast_with_retry` where `retry_manager.invocation(...).execute()` returns `RetryError` after exhausting attempts — persistent sequence mismatch, repeated node/API failures, or non-retryable errors surfaced by `should_retry`.
Common situations: Sequence/account number desync after a restart with stale sequence state, dYdX node or indexer outage, invalid transaction rejected by the node on every attempt, or network partition during bursts of orders.
Understand the failure class
Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.
Related errors
- partitioned cancel failed: {}
- Transaction broadcast failed: code={}, log={}
- Failed to connect after {max_attempts} attempts
- Failed to connect to {} after {} attempts: {}. If this is a
- All {} requests failed: {errors:?}
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/63cb091e1dd8045e.
Report an issue: GitHub.