{"record":{"id":"acc2c69cf419e525","repo":"nautechsystems/nautilus_trader","slug":"binance-futures-shutdown-failed","errorCode":null,"errorMessage":"Binance Futures shutdown failed: {}","messagePattern":"Binance Futures shutdown failed: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"warning","filePath":"crates/adapters/binance/src/futures/execution.rs","lineNumber":2172,"sourceCode":"        if let Err(e) = self\n            .close_listen_key_slot(\n                &self.recovery_listen_key,\n                \"failed to close recovery listen key\",\n            )\n            .await\n        {\n            self.shutdown_errors.push(e.to_string());\n        }\n\n        if let Err(e) = self.await_pending_tasks().await {\n            self.shutdown_errors.push(e.to_string());\n        }\n\n        self.core.set_disconnected();\n\n        if !self.shutdown_errors.is_empty() {\n            let shutdown_errors = std::mem::take(&mut self.shutdown_errors);\n            anyhow::bail!(\n                \"Binance Futures shutdown failed: {}\",\n                shutdown_errors.join(\"; \")\n            );\n        }\n        log::info!(\"Disconnected: client_id={}\", self.core.client_id);\n        Ok(())\n    }\n\n    async fn generate_order_status_report(\n        &self,\n        cmd: &GenerateOrderStatusReport,\n    ) -> anyhow::Result<Option<OrderStatusReport>> {\n        let Some(instrument_id) = cmd.instrument_id else {\n            log::warn!(\"generate_order_status_report requires instrument_id: {cmd}\");\n            return Ok(None);\n        };\n        let Some(instrument) = self.http_client.instrument_reconciliation(&instrument_id) else {\n            if self.is_instrument_out_of_scope(instrument_id) {","sourceCodeStart":2154,"sourceCodeEnd":2190,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/futures/execution.rs#L2154-L2190","documentation":"During disconnect, the client collects errors from individual shutdown steps into shutdown_errors; if any accumulated, it joins them and bails with 'Binance Futures shutdown failed' after already marking itself disconnected. The client is down, but some cleanup step(s) failed.","triggerScenarios":"Any component's shutdown path (WS streams, user-data stream, HTTP session teardown) pushes into shutdown_errors during disconnect(), commonly due to network drops while closing sockets or a listen-key delete failing.","commonSituations":"Network already down when disconnect is called; WS connection already closed by the server so the close handshake errors; timeout while deleting the Binance listen key.","solutions":["Read the joined error list in the message to identify which teardown step failed.","Confirm the client is actually disconnected (core.set_disconnected runs before the bail) — a reconnect can proceed.","Fix the underlying network/proxy issue before the next shutdown/reconnect cycle.","Treat listen-key deletion failures as benign if the key expires automatically in 24h."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match client.disconnect().await {\n    Err(e) if e.to_string().starts_with(\"Binance Futures shutdown failed\") => {\n        log::warn!(\"shutdown partially failed (client already marked disconnected): {e}\");\n        // safe to reconnect\n    }\n    other => other?,\n}","preventionTips":["Ensure network availability before graceful shutdown.","Treat listen-key delete failures as non-fatal (keys auto-expire in 24h).","Check client connection state before reconnecting after this error."],"tags":["binance","futures","disconnect","shutdown","websocket"],"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-14T00:17:10.932Z"}