{"record":{"id":"e8c523256efddedd","repo":"nautechsystems/nautilus_trader","slug":"std-mem-take-mut-self-shutdown-errors-join-e8c523","errorCode":null,"errorMessage":"std::mem::take(&mut self.shutdown_errors).join(\"; \")","messagePattern":"std::mem::take\\(&mut self\\.shutdown_errors\\)\\.join\\(\"; \"\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/coinbase/src/execution.rs","lineNumber":288,"sourceCode":"        self.abort_pending_tasks();\n\n        if let Err(e) = self.ws_user.disconnect().await {\n            self.shutdown_errors.push(e.to_string());\n        }\n        let (session_result, pending_result) =\n            tokio::join!(self.await_session_tasks(), self.await_pending_tasks());\n        self.core.set_disconnected();\n\n        if let Err(e) = session_result {\n            self.shutdown_errors.push(e.to_string());\n        }\n\n        if let Err(e) = pending_result {\n            self.shutdown_errors.push(e.to_string());\n        }\n\n        if !self.shutdown_errors.is_empty() {\n            anyhow::bail!(std::mem::take(&mut self.shutdown_errors).join(\"; \"));\n        }\n        Ok(())\n    }\n\n    // Returns true when the exec client was created with a Margin account,\n    // indicating it should handle CFM-backed derivatives traffic.\n    fn is_margin(&self) -> bool {\n        self.core.account_type == AccountType::Margin\n    }\n\n    // Returns true when the instrument resides in the connect-time bootstrap\n    // cache. For the Cash (spot) factory this gates spot-only traffic; for the\n    // Margin factory the cache contains CFM perp + future products.\n    fn is_instrument_cached(&self, instrument_id: &InstrumentId) -> bool {\n        self.instruments_cache\n            .contains_key(instrument_id.symbol.as_str())\n    }\n","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/coinbase/src/execution.rs#L270-L306","documentation":"teardown_partial_connect on the Coinbase execution client collects errors from rolling back partially-completed connect steps (e.g. failed REST/WS setup pending_result) into shutdown_errors, then fails with all messages joined by '; '. It reports why the partially-connected exec client could not be cleanly torn down.","triggerScenarios":"connect() on the execution client fails midway (e.g. account registration, WS setup) and the rollback's pending_result error, or a ws/REST disconnect error, populates shutdown_errors.","commonSituations":"Invalid API keys failing mid-connect; network outage during connect; disconnect called on an already-dead connection during rollback.","solutions":["Read the joined '; ' message to find which teardown step failed","Retry the full connect with a freshly constructed execution client rather than reusing the half-torn-down one","Verify API credentials and network reachability before connect so the partial path is not entered","If disconnect reports the socket was already closed, treat teardown as complete and recreate the client"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// pre-flight: verify credentials/network before connect\nassert!(!api_key.is_empty() && !api_secret.is_empty());","typeGuard":null,"tryCatchPattern":"if let Err(e) = exec_client.connect().await {\n    // teardown errors are '; '-joined; log then rebuild a fresh client\n    log::error!(\"coinbase exec connect/teardown failed: {e}\");\n    exec_client = CoinbaseExecClientFactory::create(...)?;\n}","preventionTips":["Verify API keys/scopes before connecting to avoid partial-connect paths","Never reuse an execution client after a teardown error — rebuild it","Serialize connect/disconnect calls per client","Parse the joined teardown messages to identify the failing step"],"tags":["teardown","execution-client","rust","cleanup"],"backgroundTag":"http-request-failed","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}