nautechsystems/nautilus_trader · error
vega pricing timeout exceeds the nanosecond range
Error message
vega pricing timeout exceeds the nanosecond range
What it means
The vega pricing timeout is configured in seconds and converted to nanoseconds with `DurationNanos::try_from_secs`, which fails when the second value exceeds u64 nanosecond range (i.e. > ~584 years, or a negative/huge f64-derived value). The `.expect` then panics.
Source
Thrown at crates/data/src/aggregation.rs:2421
if self
.clock
.borrow()
.timer_names()
.contains(&self.vega_pricing_timeout_timer_name.as_str())
{
return;
}
let Some(aggregator_weak) = self.aggregator_weak.clone() else {
return;
};
let callback = TimeEventCallback::RustLocal(Rc::new(move |_event: TimeEvent| {
if let Some(agg) = aggregator_weak.upgrade() {
agg.borrow_mut().clear_vega_pricing_timeout();
}
}));
let timeout = DurationNanos::try_from_secs(self.vega_pricing_timeout_seconds)
.expect("vega pricing timeout exceeds the nanosecond range");
let alert_time = self.clock.borrow().timestamp_ns() + timeout;
self.clock
.borrow_mut()
.set_time_alert_ns(
&self.vega_pricing_timeout_timer_name,
alert_time,
Some(callback),
Some(true),
)
.expect("Failed to set spread quote vega pricing timeout");
}
fn create_futures_spread_prices(&self) -> (f64, f64) {
let mut raw_ask = 0.0_f64;
let mut raw_bid = 0.0_f64;
for i in 0..self.leg_ids.len() {View on GitHub (pinned to 18893faf8b)
Solutions
- Set a sane timeout in seconds (e.g. 1–60) for `vega_pricing_timeout_seconds`
- Fix unit conversion at config load: if the source value is milliseconds, divide by 1000 before assigning
- Validate/limit the config value (reject NaN, negative, or > some bound) before constructing the aggregator
Example fix
// before
agg_config.vega_pricing_timeout_seconds = timeout_ms * 1000.0; // wrong direction, can overflow
// after
agg_config.vega_pricing_timeout_seconds = timeout_ms / 1000.0;
assert!(agg_config.vega_pricing_timeout_seconds.is_finite()
&& (0.0..=3600.0).contains(&agg_config.vega_pricing_timeout_seconds)); Defensive patterns
Strategy: validation
Validate before calling
// Rust: validate timeout seconds before arming
let t = config.vega_pricing_timeout_seconds;
assert!(t.is_finite() && t > 0.0 && t <= 3600.0, "invalid vega pricing timeout: {t}"); Type guard
fn valid_timeout_secs(t: f64) -> Option<f64> { t.is_finite().then(|| t).filter(|v| *v > 0.0 && *v <= 3600.0) } Try / catch
let result = std::panic::catch_unwind(|| agg.arm_vega_pricing_timeout());
Prevention
- Keep timeouts in a bounded sane range (seconds, not millis)
- Fix ms-vs-s conversion direction at config load
- Reject NaN/negative/sentinel timeout values in config validation
When it happens
Trigger: Setting `vega_pricing_timeout_seconds` to an absurd value (NaN, huge float, u64-seconds overflow) in the spread aggregator configuration before the timeout timer is armed.
Common situations: Config parsed from JSON/TOML where the timeout is in milliseconds but assigned to a seconds field multiplied incorrectly; sentinel values like f64::MAX used as 'no timeout'; unit confusion between seconds/millis in adapter config.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- DurationNanos overflow in from_micros
- {e}
- Invalid bar interval
- DurationNanos overflow in from_millis
- DurationNanos overflow in from_secs
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/c6d48dfd9088af07.
Report an issue: GitHub.