{"record":{"id":"da92a664ec326b25","repo":"nautechsystems/nautilus_trader","slug":"binance-futures-data-teardown-failed","errorCode":null,"errorMessage":"Binance Futures data teardown failed: {}","messagePattern":"Binance Futures data teardown failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/futures/data.rs","lineNumber":378,"sourceCode":"\n        if let Err(e) = self.ws_client.close().await {\n            self.shutdown_errors\n                .push(format!(\"market WebSocket close failed: {e}\"));\n        }\n\n        if let Err(e) = self.ws_public_client.close().await {\n            self.shutdown_errors\n                .push(format!(\"public WebSocket close failed: {e}\"));\n        }\n\n        if let Err(e) = self.finish_tasks().await {\n            self.shutdown_errors.push(e.to_string());\n        }\n        self.is_connected.store(false, Ordering::Release);\n\n        if !self.shutdown_errors.is_empty() {\n            let errors = std::mem::take(&mut self.shutdown_errors);\n            anyhow::bail!(\n                \"Binance Futures data teardown failed: {}\",\n                errors.join(\"; \")\n            );\n        }\n        Ok(())\n    }\n\n    #[expect(clippy::too_many_arguments)]\n    async fn refresh_instrument_catalog(\n        http: &BinanceFuturesHttpClient,\n        provider: &crate::config::BinanceInstrumentProviderConfig,\n        instruments_cache: &Arc<AtomicMap<InstrumentId, InstrumentAny>>,\n        status_cache: &Arc<AtomicMap<InstrumentId, MarketStatusAction>>,\n        ws: &BinanceFuturesWebSocketClient,\n        ws_public: &BinanceFuturesWebSocketClient,\n        sender: &tokio::sync::mpsc::UnboundedSender<DataEvent>,\n        clock: &'static AtomicTime,\n        emit_status_changes: bool,","sourceCodeStart":360,"sourceCodeEnd":396,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/futures/data.rs#L360-L396","documentation":"Aggregated error from Binance Futures data client teardown: all errors collected while closing the market/public WebSockets and finishing task groups are joined and bailed as one message. It means the partial or full shutdown did not complete cleanly.","triggerScenarios":"teardown_partial_connect runs (during a failed connect, or explicit disconnect) and any of: ws_client.close(), ws_public_client.close(), or finish_tasks() returns an error; messages are pushed to shutdown_errors and bail if non-empty.","commonSituations":"Failed initial connect that must roll back subscriptions, disconnect during a network outage, hung WebSocket sockets, or a previously failed finish_tasks pushing errors into shutdown_errors.","solutions":["Read the joined message; it enumerates the specific sub-failures (market WS close, public WS close, task finish)","Fix the root cause in the innermost error first (usually network or a hung task)","Retry connect/disconnect after the network recovers; state is reset (is_connected=false) even on failure","Avoid initiating new subscriptions while teardown is in progress","Report/upgrade if WS close consistently times out"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// check connectivity before disconnect to avoid WS close errors\nassert!(ws_health_check().await.is_ok(), \"WebSocket must be responsive before teardown\");","typeGuard":null,"tryCatchPattern":"if let Err(e) = client.disconnect().await {\n    log::error!(\"teardown: {e}\"); // message lists each sub-failure\n    // safe to retry: is_connected is already false\n    client.disconnect().await?;\n}","preventionTips":["Retry disconnect; state is reset even on failure","Avoid subscribing during teardown","Inspect joined error list for the failing sub-step"],"tags":["rust","websocket","shutdown","network"],"backgroundTag":"http-error-response","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"}