nautechsystems/nautilus_trader · info
non-zero
Error message
non-zero
What it means
COINBASE_WS_CONNECTION_QUOTA builds a governor Quota of 8 connections per second, asserting via NonZeroU32::new(8).expect("non-zero") that the rate is valid. The panic is a constant sanity check: Quota::per_second rejects zero, but 8 is a hard-coded non-zero literal, so this can never fire as shipped.
Source
Thrown at crates/adapters/coinbase/src/websocket/client.rs:71
use crate::{
common::{
consts::{
RECONNECT_BACKOFF_FACTOR, RECONNECT_BASE_BACKOFF, RECONNECT_JITTER_MS,
RECONNECT_MAX_BACKOFF, RECONNECT_TIMEOUT, WS_DISCONNECT_TIMEOUT, WS_HEARTBEAT_SECS,
},
credential::CoinbaseCredential,
enums::CoinbaseWsChannel,
},
websocket::{
handler::{FeedHandler, HandlerCommand, NautilusWsMessage},
messages::{CoinbaseWsAction, CoinbaseWsSubscription},
},
};
/// Coinbase WebSocket connection rate limit (8 per second per IP).
pub static COINBASE_WS_CONNECTION_QUOTA: LazyLock<Quota> = LazyLock::new(|| {
Quota::per_second(NonZeroU32::new(8).expect("non-zero")).expect("valid constant")
});
/// Coinbase WebSocket subscribe/unsubscribe rate limit (8 per second per IP).
pub static COINBASE_WS_SUBSCRIPTION_QUOTA: LazyLock<Quota> = LazyLock::new(|| {
Quota::per_second(NonZeroU32::new(8).expect("non-zero")).expect("valid constant")
});
/// Rate-limit key for subscribe/unsubscribe operations.
pub const COINBASE_RATE_LIMIT_KEY_SUBSCRIPTION: &str = "subscription";
/// Pre-interned [`COINBASE_RATE_LIMIT_KEY_SUBSCRIPTION`] slice.
pub static COINBASE_WS_SUBSCRIPTION_KEYS: LazyLock<[Ustr; 1]> =
LazyLock::new(|| [Ustr::from(COINBASE_RATE_LIMIT_KEY_SUBSCRIPTION)]);
/// WebSocket client for Coinbase Advanced Trade market data and user streams.
///
/// Manages connection lifecycle, subscription state, and JWT authentication.
/// Spawns a [`FeedHandler`] task that parses raw messages into Nautilus types.View on GitHub (pinned to 18893faf8b)
Solutions
- Keep the rate constant non-zero; disable connections at a higher level instead of a zero quota.
- Consider NonZeroU32 constants declared with core::num::NonZeroU32::new(8).unwrap() in a const context to fail earlier.
Example fix
// before
Quota::per_second(NonZeroU32::new(0).expect("non-zero")) // panics at init
// after
Quota::per_second(NonZeroU32::new(8).expect("non-zero")) Defensive patterns
Strategy: validation
Validate before calling
// Library-internal constant check; users cannot trigger it. Maintainers: const WS_CONNECT_RPS: u32 = 8; assert!(WS_CONNECT_RPS > 0);
Prevention
- Do not zero out rate-limit constants to disable behavior.
- Keep quota literals non-zero and documented.
When it happens
Trigger: Only if the literal 8 were edited to 0 and the static were first initialized.
Common situations: A developer tuning the WebSocket connect rate limit and setting it to 0 (intending to disable connections) triggers this panic on first use of the quota.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- non-zero
- InstrumentState channel requires kind and currency parameter
- Coinbase WebSocket handler failed: {error}
- Coinbase WebSocket handler did not stop after abort
- Failed to send SetClient command: {e}
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/6c836041f60b1de7.
Report an issue: GitHub.