{"record":{"id":"76c6084f8162bdf6","repo":"nautechsystems/nautilus_trader","slug":"cannot-cancel-orders-not-connected","errorCode":null,"errorMessage":"Cannot cancel orders: not connected","messagePattern":"Cannot cancel orders: not connected","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/dydx/src/execution/mod.rs","lineNumber":2047,"sourceCode":"                        ts_event,\n                    );\n                }\n                Err(e) => {\n                    log::warn!(\n                        \"Ambiguous dYdX cancel failure for {client_order_id}, awaiting reconciliation: {e:?}\"\n                    );\n                }\n            }\n\n            Ok(())\n        });\n\n        Ok(())\n    }\n\n    fn cancel_all_orders(&self, cmd: CancelAllOrders) -> anyhow::Result<()> {\n        if !self.is_connected() {\n            anyhow::bail!(\"Cannot cancel orders: not connected\");\n        }\n\n        let instrument_id = cmd.instrument_id;\n        let order_side_filter = cmd.order_side;\n\n        let order_data: Vec<CancelAllOrderData> = {\n            let cache = self.core.cache();\n            let side_filter = order_side_filter;\n            cache\n                .orders_open(None, Some(&instrument_id), None, None, side_filter)\n                .into_iter()\n                .map(|order| {\n                    (\n                        order.strategy_id(),\n                        order.client_order_id(),\n                        order.venue_order_id(),\n                        order.time_in_force(),\n                        order.expire_time(),","sourceCodeStart":2029,"sourceCodeEnd":2065,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/dydx/src/execution/mod.rs#L2029-L2065","documentation":"`cancel_all_orders` checks connectivity before gathering open orders and broadcasting partitioned cancels. If the client is disconnected it bails immediately because mass-cancellation requires a live chain link.","triggerScenarios":"Calling `cancel_all_orders` when `is_connected()` is false — before connect completes, after disconnect, or during reconnect.","commonSituations":"Emergency flatten during a network outage; market-close routines racing an already-dropped connection; adapter shutdown ordering.","solutions":["Reconnect the client, then retry cancel_all_orders","Check network/dYdX endpoint health","Verify order state via reconciliation once reconnected — orders may have expired already"],"exampleFix":"// before\nclient.cancel_all_orders(cmd)?;\n// after\nif !client.is_connected() {\n    client.connect().await?;\n}\nclient.cancel_all_orders(cmd)?;","handlingStrategy":"validation","validationCode":"if !client.is_connected() { return Err(anyhow!(\"client not connected\")); }","typeGuard":null,"tryCatchPattern":"if let Err(e) = client.cancel_all_orders(cmd) {\n    if e.to_string().contains(\"not connected\") { /* defer until reconnected */ }\n}","preventionTips":["Queue mass-cancels and flush on reconnect","Run cancel_all only with a healthy connection monitor","Reconcile venue state after reconnect to avoid redundant cancels"],"tags":["dydx","connectivity","order-cancellation"],"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"}