{"record":{"id":"cc68efaa3e3271f4","repo":"nautechsystems/nautilus_trader","slug":"std-mem-take-mut-self-shutdown-errors-join-cc68ef","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/architect_ax/src/execution.rs","lineNumber":452,"sourceCode":"        if let Err(e) = self.ws_orders.close().await {\n            self.shutdown_errors\n                .push(format!(\"AX orders WebSocket shutdown failed: {e}\"));\n        }\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    /// Polls the cache until the account is registered or timeout is reached.\n    async fn await_account_registered(&self, timeout_secs: f64) -> anyhow::Result<()> {\n        let account_id = self.core.account_id;\n\n        if self.core.cache().account(&account_id).is_some() {\n            log::info!(\"Account {account_id} registered\");\n            return Ok(());\n        }\n\n        let start = Instant::now();\n        let timeout = Duration::from_secs_f64(timeout_secs);\n        let interval = Duration::from_millis(10);\n\n        loop {","sourceCodeStart":434,"sourceCodeEnd":470,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/architect_ax/src/execution.rs#L434-L470","documentation":"Identical pattern to the data client: AX execution client's `teardown_partial_connect` drains self.shutdown_errors and bails with them joined by ';'. It indicates the execution connect failed partway and cleanup steps (e.g. awaiting pending results) also reported errors.","triggerScenarios":"connect() on AXExecutionClient partially succeeds then fails (auth rejected, account lookup fails), and teardown tasks/pending results return errors.","commonSituations":"Invalid API credentials; AX execution gateway down; timeout races during client startup.","solutions":["Parse the joined messages to identify the root failure versus secondary teardown errors","Fix the underlying connect problem (credentials, gateway URL, network) and reconnect","Check whether the pending-result error indicates an unresponsive gateway needing a longer timeout"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Validate credentials and gateway URL before constructing the execution client\nif api_key.is_empty() || gateway_url.is_empty() { return Err(\"missing AX exec config\"); }","typeGuard":null,"tryCatchPattern":"match exec_client.connect().await {\n    Ok(()) => {},\n    Err(e) => { log::error!(\"AX exec connect failed: {e}\"); /* fix root cause, then reconnect */ }\n}","preventionTips":["Pre-flight credential validation against the AX auth endpoint","Give teardown generous timeouts so pending results can settle","Alert on the first message in the joined error string, which usually names the primary failure"],"tags":["rust","adapter","connection","lifecycle","execution"],"backgroundTag":"connection-refused","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"}