{"record":{"id":"13b57fbda2ce4e05","repo":"nautechsystems/nautilus_trader","slug":"binance-spot-shutdown-failed","errorCode":null,"errorMessage":"Binance Spot shutdown failed: {}","messagePattern":"Binance Spot shutdown failed: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/spot/execution.rs","lineNumber":818,"sourceCode":"                .push(format!(\"trading WebSocket shutdown failed: {e}\"));\n        }\n        self.disconnect_us_user_data().await;\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            let errors = std::mem::take(&mut self.shutdown_errors);\n            anyhow::bail!(\"Binance Spot shutdown failed: {}\", errors.join(\"; \"));\n        }\n        Ok(())\n    }\n}\n\n#[async_trait(?Send)]\nimpl ExecutionClient for BinanceSpotExecutionClient {\n    fn is_connected(&self) -> bool {\n        self.core.is_connected()\n    }\n\n    fn client_id(&self) -> ClientId {\n        self.core.client_id\n    }\n\n    fn account_id(&self) -> AccountId {\n        self.core.account_id\n    }","sourceCodeStart":800,"sourceCodeEnd":836,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/spot/execution.rs#L800-L836","documentation":"Aggregate shutdown error for the Binance Spot execution client: `teardown_partial_connect` collects every failure that occurred while tearing down a partially-established connection (or during normal disconnect) into `shutdown_errors` and bails with all messages joined by \"; \". It signals that one or more teardown steps (stream closures, unsubscriptions, connection cleanup) failed.","triggerScenarios":"`connect` or `disconnect` fails partway and invokes `teardown_partial_connect`; any teardown step pushes an error into `self.shutdown_errors`, producing this combined error at the end of teardown.","commonSituations":"Network already down when disconnecting (streams cannot be closed gracefully); connect failure mid-way (e.g. auth stream connected but market stream not), triggering partial teardown; broker/endpoint refusing close frames.","solutions":["Read the joined sub-errors after 'Binance Spot shutdown failed:' to identify which teardown step(s) failed","Address the root cause (usually the same network/auth problem that caused the connect/disconnect failure)","Reconnect with a fresh ExecutionClient instance — the adapter state was reset via std::mem::take","If disconnect errors are benign during shutdown, treat them as non-fatal for process exit but fix for long-running reconnect loops"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if let Err(e) = client.disconnect().await {\n    log::error!(\"shutdown incomplete: {e}\");\n    // recreate the client before next use\n}","preventionTips":["Avoid calling connect/disconnect concurrently","Verify network availability before connect attempts","Inspect the ';'-joined sub-errors to find the failing teardown step","Rebuild the client instance after a failed teardown"],"tags":["binance","spot","shutdown","teardown","connection"],"backgroundTag":"invalid-state-transition","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"}