{"record":{"id":"cf69d8f92cf9766a","repo":"nautechsystems/nautilus_trader","slug":"failed-to-send-order-modify-rejected-event-e","errorCode":null,"errorMessage":"Failed to send order modify rejected event: {e}","messagePattern":"Failed to send order modify rejected event: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/interactive_brokers/src/execution/core.rs","lineNumber":1951,"sourceCode":"        ts_event: UnixNanos,\n        account_id: AccountId,\n    ) -> anyhow::Result<()> {\n        let event = OrderModifyRejected::new(\n            cmd.trader_id,\n            cmd.strategy_id,\n            cmd.instrument_id,\n            cmd.client_order_id,\n            Ustr::from(reason),\n            UUID4::new(),\n            ts_event,\n            ts_event,\n            false,\n            cmd.venue_order_id,\n            Some(account_id),\n        );\n        exec_sender\n            .send(ExecutionEvent::Order(OrderEventAny::ModifyRejected(event)))\n            .map_err(|e| anyhow::anyhow!(\"Failed to send order modify rejected event: {e}\"))\n    }\n\n    fn send_order_cancel_rejected(\n        target_order: &OrderAny,\n        reason: &str,\n        exec_sender: &tokio::sync::mpsc::UnboundedSender<ExecutionEvent>,\n        ts_event: UnixNanos,\n        account_id: AccountId,\n    ) -> anyhow::Result<()> {\n        let event = OrderCancelRejected::new(\n            target_order.trader_id(),\n            target_order.strategy_id(),\n            target_order.instrument_id(),\n            target_order.client_order_id(),\n            Ustr::from(reason),\n            UUID4::new(),\n            ts_event,\n            ts_event,","sourceCodeStart":1933,"sourceCodeEnd":1969,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/interactive_brokers/src/execution/core.rs#L1933-L1969","documentation":"Same channel-closed family as 3163: `send_order_modify_rejected` sends an `OrderEventAny::ModifyRejected` event on the provided `exec_sender` unbounded mpsc channel. Failure means the receiver is gone, so the modify-rejection cannot be delivered and the error is wrapped and returned.","triggerScenarios":"IB rejects an order modify request and the adapter calls `send_order_modify_rejected`, but the `exec_sender`'s receiver was dropped (event loop stopped, node tearing down, or the sender passed in belongs to a dead receiver).","commonSituations":"Late modify-reject arriving during shutdown; cancel-and-replace failing after the execution engine stopped; misconfigured exec routing so the receiver was closed.","solutions":["Keep the execution event receiver alive until all adapter senders are dropped; stop the adapter first during shutdown.","Verify the exec event channel routing/wiring so the sender passed to this helper still has a live receiver.","Log and ignore if strictly during teardown, since no consumer exists for the event anymore."],"exampleFix":"// before\nexec_sender\n    .send(ExecutionEvent::Order(OrderEventAny::ModifyRejected(event)))\n    .map_err(|e| anyhow::anyhow!(\"Failed to send order modify rejected event: {e}\"))\n// after\nif let Err(e) = exec_sender.send(ExecutionEvent::Order(OrderEventAny::ModifyRejected(event))) {\n    log::error!(\"modify rejected event not delivered: {e}\");\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"Failed to send order modify rejected event\") => {\n        log::warn!(\"modify rejection not delivered (receiver closed): {e}\");\n    }\n    other => other?,\n}","preventionTips":["Sequence shutdown: cancel/modify traffic quiesced, adapter disconnected, then engine dropped.","Route all exec events through the engine-owned sender with the receiver joined last.","In tests, assert receivers outlive all senders (tokio mpsc semantics)."],"tags":["rust","tokio","mpsc-channel","event-delivery"],"backgroundTag":"mpsc-channel-closed","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"}