{"record":{"id":"5a064d9793b90a0b","repo":"nautechsystems/nautilus_trader","slug":"errors-joined-with-aggregated-disconnect-err-5a064d","errorCode":null,"errorMessage":"errors joined with \"; \" (aggregated disconnect errors)","messagePattern":"errors joined with \"; \" \\(aggregated disconnect errors\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/deribit/src/execution.rs","lineNumber":236,"sourceCode":"        if let Err(e) = self.ws_client.close().await {\n            errors.push(format!(\"WebSocket shutdown failed: {e}\"));\n        }\n        let (session_result, pending_result) =\n            tokio::join!(self.await_session_tasks(), self.await_pending_tasks());\n\n        if let Err(e) = session_result {\n            errors.push(e.to_string());\n        }\n\n        if let Err(e) = pending_result {\n            errors.push(e.to_string());\n        }\n        self.core.set_disconnected();\n\n        if errors.is_empty() {\n            Ok(())\n        } else {\n            anyhow::bail!(errors.join(\"; \"))\n        }\n    }\n\n    // Rejects unsupported order types and time-in-force values\n    fn build_order_params(order: &dyn Order) -> anyhow::Result<DeribitOrderParams> {\n        let order_type = match order.order_type() {\n            OrderType::Limit => \"limit\",\n            OrderType::Market => \"market\",\n            OrderType::StopLimit => \"stop_limit\",\n            OrderType::StopMarket => \"stop_market\",\n            OrderType::LimitIfTouched => \"take_limit\",\n            OrderType::MarketIfTouched => \"take_market\",\n            other => {\n                anyhow::bail!(\"Unsupported order type {other:?} for Deribit\");\n            }\n        }\n        .to_string();\n","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/deribit/src/execution.rs#L218-L254","documentation":"The execution (trading) client has its own teardown_partial_connect used on disconnect and failed connects. It shuts down session/pending tasks and, if any step produced an error, returns them aggregated as one message joined by \"; \". It indicates the trading connection did not tear down cleanly.","triggerScenarios":"Calling exec client disconnect(), or connect() failing partway (credentials/auth/WS setup), so teardown runs and any task shutdown or channel close errors are collected into a non-empty errors vec.","commonSituations":"Open orders with pending tasks at disconnect; WS already dead after a network drop so shutdown signaling fails; auth failure during connect leaving partially initialized state; double disconnect.","solutions":["Parse each \"; \"-separated segment to find the concrete failing teardown step","Check Deribit API connectivity and credentials before reconnecting","Avoid disconnecting while order tasks are pending; await/drain pending tasks first","Inspect TaskGroupGuard shutdown logic if a task join consistently hangs or errors"],"exampleFix":"// before\nmatch client.disconnect().await { _ => {} }\n// after\nif let Err(e) = client.disconnect().await {\n    e.to_string().split(\"; \").for_each(|c| tracing::error!(%c, \"teardown\"));\n}","handlingStrategy":"try-catch","validationCode":"// Drain pending order tasks before teardown\nassert!(pending_tasks_done(), \"await pending order tasks before disconnect\");","typeGuard":null,"tryCatchPattern":"if let Err(e) = exec_client.disconnect().await {\n    e.to_string().split(\"; \").for_each(|c| log::error!(\"exec teardown: {c}\"));\n}","preventionTips":["Wait for pending order tasks to complete before disconnecting","Check WS connectivity; don't disconnect after the link is already dead without handling errors","Guard against double-disconnect with connection state tracking"],"tags":["websocket","teardown","execution","rust","deribit"],"backgroundTag":"network-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"}