nautechsystems/nautilus_trader · error
Polymarket RTDS task shutdown failed: {}
Error message
Polymarket RTDS task shutdown failed: {} What it means
take_shutdown_result collects per-task shutdown errors recorded during RTDS teardown; if any exist, it joins them and fails. The RTDS (real-time data stream) background tasks reported failures while stopping, so shutdown did not complete cleanly.
Source
Thrown at crates/adapters/polymarket/src/rtds.rs:132
if self.ws.is_some() {
*self.owner.lock() = self.ws.take();
}
}
}
impl RtdsTaskSlots {
fn push_shutdown_error(&self, error: String) {
self.shutdown_errors.lock().push(error);
}
fn take_shutdown_result(&self) -> anyhow::Result<()> {
let mut errors = self.shutdown_errors.lock();
if errors.is_empty() {
Ok(())
} else {
let errors = std::mem::take(&mut *errors);
anyhow::bail!(
"Polymarket RTDS task shutdown failed: {}",
errors.join("; ")
)
}
}
}
impl Drop for RtdsTaskSlots {
fn drop(&mut self) {
self.message.get_mut().abort();
self.reconcile.get_mut().abort();
}
}
#[derive(Debug)]
struct PolymarketRtdsFeedInner {
url: String,
proxy_url: Option<ProxyUrl>,View on GitHub (pinned to 18893faf8b)
Solutions
- Inspect the joined error messages after this error to identify which task failed
- Ensure shutdown is awaited and the client is not dropped concurrently while tasks run
- Retry shutdown once tasks have settled; if transient network noise, it is usually safe after confirming sockets are closed
Example fix
// before drop(client); // tasks shut down with errors, surfaced later // after client.shutdown().await?; // logs per-task errors, cleans shutdown
Defensive patterns
Strategy: try-catch
Try / catch
match client.shutdown().await {
Err(e) if e.to_string().starts_with("Polymarket RTDS task shutdown failed") => {
log::warn!("RTDS shutdown errors: {e}"); // usually benign during teardown
}
r => r?,
} Prevention
- Always await shutdown instead of dropping the client mid-stream
- Avoid concurrent calls to connect/shutdown
- Keep network stability in mind during teardown; log rather than panic
When it happens
Trigger: Calling shutdown/take_shutdown_result when one or more RTDS tasks (websocket, reconcile workers) errored during cancellation — e.g. write-after-close on the socket, task panicked, or channel send failed during teardown.
Common situations: Abrupt network loss at shutdown time; dropping the client while tasks are mid-message; platform-specific socket close races.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- RTDS connect was canceled by shutdown
- Architect AX data WebSocket handler failed: {error}
- Failed to terminate Coinbase session tasks: {e}
- failed to finish Binance Futures data command tasks: {e}
- Binance Futures data teardown failed: {}
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/7595eb8499196f31.
Report an issue: GitHub.