{"record":{"id":"dcb144f50b390e0a","repo":"nautechsystems/nautilus_trader","slug":"failed-to-send-order-canceled-event-e","errorCode":null,"errorMessage":"Failed to send order canceled event: {e}","messagePattern":"Failed to send order canceled event: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/interactive_brokers/src/execution/core_updates.rs","lineNumber":603,"sourceCode":"                    strategy_id_map,\n                )?;\n\n                let event = OrderCanceled::new(\n                    trader_id,\n                    strategy_id,\n                    instrument_id,\n                    client_order_id,\n                    UUID4::new(),\n                    ts_init,\n                    ts_init,\n                    false,\n                    Some(venue_order_id),\n                    Some(account_id),\n                    None,\n                );\n                exec_sender\n                    .send(ExecutionEvent::Order(OrderEventAny::Canceled(event)))\n                    .map_err(|e| anyhow::anyhow!(\"Failed to send order canceled event: {e}\"))?;\n                tracing::debug!(\"Order {} canceled\", client_order_id);\n            }\n            Some(IbOrderStatus::PendingCancel) => {\n                Self::emit_order_pending_cancel(\n                    status.order_id,\n                    client_order_id,\n                    venue_order_id,\n                    instrument_id_map,\n                    trader_id_map,\n                    strategy_id_map,\n                    pending_cancel_orders,\n                    exec_sender,\n                    ts_init,\n                    account_id,\n                )?;\n                tracing::debug!(\"Order {} pending cancel\", client_order_id);\n            }\n            _ => {","sourceCodeStart":585,"sourceCodeEnd":621,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/interactive_brokers/src/execution/core_updates.rs#L585-L621","documentation":"The adapter received an order-canceled status from IB but could not forward the resulting OrderCanceled event through the exec_sender channel because the receiver was dropped. Like the other send failures in core_updates.rs, it signals that the execution event pipeline is no longer accepting events while IB callbacks continue to arrive.","triggerScenarios":"handle_order_status matches IbOrderStatus::Cancelled, builds an OrderCanceled event, and calls exec_sender.send(...); the send fails because the channel receiver was dropped or closed before this callback ran.","commonSituations":"Node/engine stopped or cancelled while IB Gateway still reports cancellations; race between engine shutdown and in-flight order status messages; consumer task terminated by an earlier error.","solutions":["Keep the ExecutionEngine/event receiver alive until the IB adapter is fully disconnected.","Disconnect the IB client and stop order-status handling before dropping the receiver during shutdown.","Treat send failures during intentional shutdown as benign and log them instead of erroring."],"exampleFix":"// before\nexec_sender\n    .send(ExecutionEvent::Order(OrderEventAny::Canceled(event)))\n    .map_err(|e| anyhow::anyhow!(\"Failed to send order canceled event: {e}\"))?;\n// after\nif let Err(e) = exec_sender.send(ExecutionEvent::Order(OrderEventAny::Canceled(event))) {\n    tracing::warn!(\"Execution channel closed, dropping order canceled event: {e}\");\n}\ntracing::debug!(\"Order {} canceled\", client_order_id);","handlingStrategy":"try-catch","validationCode":"// Rust: skip event emission if the consumer is gone\nif exec_sender.is_closed() {\n    tracing::warn!(\"Execution event channel closed; order canceled event dropped\");\n    return Ok(());\n}","typeGuard":"fn receiver_alive(sender: &mpsc::Sender<ExecutionEvent>) -> bool {\n    !sender.is_closed()\n}","tryCatchPattern":"if let Err(e) = exec_sender.send(ExecutionEvent::Order(OrderEventAny::Canceled(event))) {\n    tracing::warn!(\"Order canceled event dropped: {e}\");\n}","preventionTips":["Keep the ExecutionEngine running until the IB adapter reports disconnected","Drain in-flight IB order status callbacks before shutdown completes","Add integration tests that cancel orders during shutdown"],"tags":["channel","messaging","shutdown","rust"],"backgroundTag":"broken-pipe","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"}