nautechsystems/nautilus_trader · error
Failed to terminate Coinbase execution tasks: {e}
Error message
Failed to terminate Coinbase execution tasks: {e} What it means
`await_pending_tasks` begins shutdown of the execution client's pending-task set and awaits completion with a 1s drain and 2s timeout (called from connect during reconnect). Failure is wrapped in this error.
Source
Thrown at crates/adapters/coinbase/src/execution.rs:255
log::warn!("Skipping Coinbase {description} after shutdown began: {e}");
}
}
fn abort_pending_tasks(&self) {
self.pending_tasks.begin_shutdown();
}
fn abort_session_tasks(&self) {
self.session_tasks.begin_shutdown();
self.ws_user.begin_shutdown();
}
async fn await_pending_tasks(&self) -> anyhow::Result<()> {
self.pending_tasks.begin_shutdown();
self.pending_tasks
.finish_shutdown(Duration::from_secs(1), Duration::from_secs(2))
.await
.map_err(|e| anyhow::anyhow!("Failed to terminate Coinbase execution tasks: {e}"))?;
Ok(())
}
async fn await_session_tasks(&self) -> anyhow::Result<()> {
self.session_tasks.begin_shutdown();
self.session_tasks
.finish_shutdown(Duration::from_secs(1), Duration::from_secs(2))
.await
.map_err(|e| anyhow::anyhow!("Failed to terminate Coinbase session tasks: {e}"))?;
Ok(())
}
async fn teardown_partial_connect(&mut self) -> anyhow::Result<()> {
self.abort_session_tasks();
self.abort_pending_tasks();
if let Err(e) = self.ws_user.disconnect().await {
self.shutdown_errors.push(e.to_string());View on GitHub (pinned to 18893faf8b)
Solutions
- Retry connect after letting prior tasks settle
- Check logs for the hung/panicked pending task and fix its cause
- Verify network connectivity to Coinbase before reconnecting
- Fully recreate the execution client if task state is stuck
- Increase the shutdown timeout in await_pending_tasks
Example fix
// before client.disconnect().await?; client.connect().await?; // may race pending-task teardown // after client.disconnect().await?; tokio::time::sleep(Duration::from_secs(3)).await; client.connect().await?;
Defensive patterns
Strategy: retry
Try / catch
for attempt in 0..3 {
match client.connect().await {
Ok(_) => break,
Err(e) if e.to_string().contains("Failed to terminate Coinbase execution tasks") => {
tokio::time::sleep(Duration::from_millis(1000 * (attempt + 1))).await;
}
Err(e) => return Err(e),
}
} Prevention
- Add a cooldown between disconnect and reconnect
- Monitor for pending requests that stall on dead sockets
- Bound reconnect attempts with exponential backoff
When it happens
Trigger: Calling connect() when a previous generation of pending execution tasks (orders in flight, pending requests) is still shutting down and a task hangs or panics past the 2s timeout.
Common situations: Rapid disconnect/reconnect cycles on the trading client; a pending order request blocked on a stalled WebSocket/HTTP connection to Coinbase.
Understand the failure class
Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.
Related errors
- Failed to finish Coinbase poll tasks: {e}
- Failed to terminate Coinbase session tasks: {e}
- Failed to start Coinbase task generation: {e}
- Failed to terminate Lighter tasks: {}
- Polymarket RTDS task shutdown failed: {}
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/26348d9a2dfa9369.
Report an issue: GitHub.