{"record":{"id":"26348d9a2dfa9369","repo":"nautechsystems/nautilus_trader","slug":"failed-to-terminate-coinbase-execution-tasks-e","errorCode":null,"errorMessage":"Failed to terminate Coinbase execution tasks: {e}","messagePattern":"Failed to terminate Coinbase execution tasks: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/coinbase/src/execution.rs","lineNumber":255,"sourceCode":"            log::warn!(\"Skipping Coinbase {description} after shutdown began: {e}\");\n        }\n    }\n\n    fn abort_pending_tasks(&self) {\n        self.pending_tasks.begin_shutdown();\n    }\n\n    fn abort_session_tasks(&self) {\n        self.session_tasks.begin_shutdown();\n        self.ws_user.begin_shutdown();\n    }\n\n    async fn await_pending_tasks(&self) -> anyhow::Result<()> {\n        self.pending_tasks.begin_shutdown();\n        self.pending_tasks\n            .finish_shutdown(Duration::from_secs(1), Duration::from_secs(2))\n            .await\n            .map_err(|e| anyhow::anyhow!(\"Failed to terminate Coinbase execution tasks: {e}\"))?;\n        Ok(())\n    }\n\n    async fn await_session_tasks(&self) -> anyhow::Result<()> {\n        self.session_tasks.begin_shutdown();\n        self.session_tasks\n            .finish_shutdown(Duration::from_secs(1), Duration::from_secs(2))\n            .await\n            .map_err(|e| anyhow::anyhow!(\"Failed to terminate Coinbase session tasks: {e}\"))?;\n        Ok(())\n    }\n\n    async fn teardown_partial_connect(&mut self) -> anyhow::Result<()> {\n        self.abort_session_tasks();\n        self.abort_pending_tasks();\n\n        if let Err(e) = self.ws_user.disconnect().await {\n            self.shutdown_errors.push(e.to_string());","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/coinbase/src/execution.rs#L237-L273","documentation":"`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.","triggerScenarios":"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.","commonSituations":"Rapid disconnect/reconnect cycles on the trading client; a pending order request blocked on a stalled WebSocket/HTTP connection to Coinbase.","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"],"exampleFix":"// before\nclient.disconnect().await?;\nclient.connect().await?; // may race pending-task teardown\n// after\nclient.disconnect().await?;\ntokio::time::sleep(Duration::from_secs(3)).await;\nclient.connect().await?;","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"for attempt in 0..3 {\n    match client.connect().await {\n        Ok(_) => break,\n        Err(e) if e.to_string().contains(\"Failed to terminate Coinbase execution tasks\") => {\n            tokio::time::sleep(Duration::from_millis(1000 * (attempt + 1))).await;\n        }\n        Err(e) => return Err(e),\n    }\n}","preventionTips":["Add a cooldown between disconnect and reconnect","Monitor for pending requests that stall on dead sockets","Bound reconnect attempts with exponential backoff"],"tags":["rust","async","tasks","shutdown","execution"],"backgroundTag":"request-timeout","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}