{"record":{"id":"1af5103e82f97369","repo":"nautechsystems/nautilus_trader","slug":"failed-to-cancel-all-orders","errorCode":null,"errorMessage":"failed to cancel all orders","messagePattern":"failed to cancel all orders","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/polymarket/src/execution/cancellations.rs","lineNumber":413,"sourceCode":"                        } else {\n                            log::debug!(\n                                \"Cancel-all response omitted local order {} ({})\",\n                                order.client_order_id(),\n                                venue_order_id\n                            );\n                        }\n                    }\n\n                    log::debug!(\n                        \"Cancel-all completed for instrument_id={instrument_id}: canceled={}, not_canceled={}\",\n                        response.canceled.len(),\n                        response.not_canceled.len()\n                    );\n                    Ok(())\n                }\n                Err(e) => {\n                    apply_cancel_http_failure(&e, &orders, &emitter, clock);\n                    Err(anyhow::Error::new(e).context(\"failed to cancel all orders\"))\n                }\n            }\n        });\n        anyhow::ensure!(spawned, \"Polymarket execution client is shutting down\");\n\n        Ok(())\n    }\n\n    pub(super) fn batch_cancel_orders_command(&self, cmd: &BatchCancelOrders) {\n        if cmd.cancels.is_empty() {\n            return;\n        }\n\n        let mut orders = Vec::new();\n\n        for c in &cmd.cancels {\n            if let Some(order) = self.core.cache().order(&c.client_order_id) {\n                orders.push(order.clone());","sourceCodeStart":395,"sourceCodeEnd":431,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/polymarket/src/execution/cancellations.rs#L395-L431","documentation":"Polymarket's cancel_all_orders_command sends a bulk cancel-all request to the CLOB API. On an Err response it applies the HTTP failure to each order (emitting denied/failed events) and returns \"failed to cancel all orders\". It indicates the venue-level cancel-all did not succeed.","triggerScenarios":"Calling cancel_all_orders when the Polymarket CLOB bulk-cancel HTTP call fails: auth rejection, network failure, non-2xx response, or service unavailability. Note the failure is applied per-order via apply_cancel_http_failure before the error is returned.","commonSituations":"Polymarket CLOB downtime or degraded service; expired API credentials/nonce desync; proxy or firewall blocking the endpoint; rate limiting after heavy cancel traffic.","solutions":["Read the wrapped underlying error for the HTTP status / CLOB error code.","Verify Polymarket API credentials and nonce synchronization; refresh API keys.","Retry after a backoff if the cause is rate limiting or transient service unavailability.","Fall back to per-order cancels for instruments where cancel-all failed.","Check network/proxy connectivity to the CLOB endpoint."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// verify endpoint reachability and credentials before bulk cancel\nassert!(clob_health_check().is_ok(), \"CLOB endpoint reachable\");\nassert!(!api_key_expired(), \"credentials valid\");","typeGuard":null,"tryCatchPattern":"if let Err(e) = client.cancel_all_orders(&instrument_id, side) {\n    warn!(\"cancel-all failed: {e}\");\n    sleep_exponential_backoff();\n    client.cancel_all_orders(&instrument_id, side)?;\n}","preventionTips":["Monitor Polymarket CLOB service status before mass cancels","Refresh API keys/nonces proactively","Apply backoff between retry attempts to respect rate limits","Fall back to per-order cancels when cancel-all fails"],"tags":["polymarket","cancel-all","http","clob"],"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"}