{"record":{"id":"acc380d8baf8e18e","repo":"nautechsystems/nautilus_trader","slug":"ws-cancel-order-failed-e-acc380","errorCode":null,"errorMessage":"WS cancel order failed: {e}","messagePattern":"WS cancel order failed: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/spot/execution.rs","lineNumber":474,"sourceCode":"                request_id.clone(),\n                PendingRequest {\n                    client_order_id: command.client_order_id,\n                    venue_order_id: command.venue_order_id,\n                    operation: PendingOperation::Cancel,\n                },\n            );\n\n            self.spawn_task(\"cancel_order_ws\", async move {\n                if let Err(e) = ws_client\n                    .cancel_order_with_id(request_id.clone(), params)\n                    .await\n                {\n                    dispatch_state.pending_requests.remove(&request_id);\n                    log::warn!(\n                        \"WS cancel request failed for {}, awaiting reconciliation: {e}\",\n                        command.client_order_id\n                    );\n                    anyhow::bail!(\"WS cancel order failed: {e}\");\n                }\n                Ok(())\n            });\n        } else {\n            let http_client = self.http_client.clone();\n            let dispatch_state = self.dispatch_state.clone();\n            log::debug!(\"WS trading not active, falling back to HTTP for cancel_order\");\n\n            self.spawn_task(\"cancel_order_http\", async move {\n                let result = http_client\n                    .cancel_order(\n                        command.instrument_id,\n                        command.venue_order_id,\n                        Some(command.client_order_id),\n                    )\n                    .await;\n\n                match result {","sourceCodeStart":456,"sourceCodeEnd":492,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/a4b06ed870971b5671d12754ea138a3ab99b1dec/crates/adapters/binance/src/spot/execution.rs#L456-L492","documentation":"The WebSocket counterpart of cancel: when the WS order transport is active, cancel_order_with_id sends the cancel over the Binance Spot WS API. On failure the pending request id is removed, a warning about awaiting reconciliation is logged, and the spawned 'cancel_order_ws' task bails with this error — the order's cancellation state is unknown until reconciled.","triggerScenarios":"The WS cancel request fails inside the spawned task: session/logon errors, WS rate limits, disconnects, or the venue rejecting the cancel (e.g. order already filled) while the transport was still considered active.","commonSituations":"Cancel bursts hitting WS rate limits during volatile markets; session drops mid-cancel; orders that fill concurrently so the cancel arrives too late and surfaces as an error.","solutions":["Trigger/await reconciliation so the order's venue state is refreshed, then decide whether to re-cancel","Retry the cancel with backoff once the WS session is healthy","Set use_ws_trading=false to send cancels over HTTP REST instead"],"exampleFix":"# before\nconfig = BinanceExecClientConfig(use_ws_trading=True)  # WS cancel fails intermittently\n\n# after: cancels over REST\nconfig = BinanceExecClientConfig(use_ws_trading=False)","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// on 'WS cancel order failed':\n//   1. reconcile the order via order status reports\n//   2. still open  -> re-send cancel after backoff\n//   3. filled/gone -> adopt state, nothing to cancel\n// never loop cancels without reconciling in between","preventionTips":["Space out cancel bursts to stay under WS rate limits","Reconcile before re-cancelling to avoid cancelling a re-filled order twice","Fall back to use_ws_trading=false (REST cancels) when WS reliability is poor"],"tags":["binance","spot","websocket","order-cancel","execution","reconciliation"],"backgroundTag":"order-cancel-failed","analyzedSha":"a4b06ed870971b5671d12754ea138a3ab99b1dec","analyzedAt":"2026-08-16T22:54:50.089Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}