{"record":{"id":"b55fd59633d6dee4","repo":"nautechsystems/nautilus_trader","slug":"failed-to-send-order-event-e","errorCode":null,"errorMessage":"Failed to send order event: {e}","messagePattern":"Failed to send order event: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/live/src/execution/emitter.rs","lineNumber":444,"sourceCode":"    pub fn send_order_event(&self, event: OrderEventAny) {\n        if let Err(e) = self.try_send_order_event(event) {\n            log::warn!(\"{e}\");\n        }\n    }\n\n    /// Emits an order event and returns any channel error to the caller.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the sender is uninitialized or its receiver is closed.\n    pub fn try_send_order_event(&self, event: OrderEventAny) -> anyhow::Result<()> {\n        let sender = self.sender.load();\n        let sender = sender\n            .as_ref()\n            .ok_or_else(|| anyhow::anyhow!(\"Cannot send order event: sender not initialized\"))?;\n        sender\n            .send(ExecutionEvent::Order(event))\n            .map_err(|e| anyhow::anyhow!(\"Failed to send order event: {e}\"))\n    }\n\n    /// Emits a batch of order submitted events as a single channel message.\n    pub fn send_order_submitted_batch(&self, batch: OrderSubmittedBatch) {\n        let sender = self.sender.load();\n        if let Some(sender) = sender.as_ref() {\n            if let Err(e) = sender.send(ExecutionEvent::OrderSubmittedBatch(batch)) {\n                log::warn!(\"Failed to send order submitted batch: {e}\");\n            }\n        } else {\n            log::warn!(\"Cannot send order submitted batch: sender not initialized\");\n        }\n    }\n\n    /// Emits a batch of order accepted events as a single channel message.\n    pub fn send_order_accepted_batch(&self, batch: OrderAcceptedBatch) {\n        let sender = self.sender.load();\n        if let Some(sender) = sender.as_ref() {","sourceCodeStart":426,"sourceCodeEnd":462,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/live/src/execution/emitter.rs#L426-L462","documentation":"try_send_order_event obtained a valid sender but the underlying channel send failed, meaning the receiving end of the execution event channel has been dropped/closed. The wrapped channel error `e` is included in the message. This typically indicates the consumer (execution engine) has shut down or been torn down while a producer still tries to emit.","triggerScenarios":"Calling try_send_order_event after the receiver side of the channel was dropped — e.g. during node shutdown, after the execution engine was stopped, or when the event stream consumer panicked and its task exited.","commonSituations":"Emitting order events during teardown; reconnect handlers firing while the engine is being restarted; a stuck/crashed consuming task causing the channel to be closed (in unbounded/bounded channel semantics where send fails when receiver is gone).","solutions":["Check whether the execution engine/node was stopped before this call; stop emitting after shutdown begins.","Reorder lifecycle so recovery/reconnect emissions happen only while the receiver is alive.","Log and tolerate this error during shutdown races instead of treating it as fatal.","Inspect the included channel error `e` to confirm the receiver-closed cause."],"exampleFix":"// before\nemitter.try_send_order_event(event)?;\n// after\nif let Err(e) = emitter.try_send_order_event(event) {\n    log::warn!(\"order event not delivered (engine likely stopped): {e}\");\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if let Err(e) = emitter.try_send_order_event(event) { log::warn!(\"order event undelivered (receiver closed?): {e}\"); }","preventionTips":["Stop event emission before shutting down the node","Detect receiver-closed conditions and back off instead of retry-spamming","Monitor for shutdown races between engine teardown and adapter callbacks"],"tags":["rust","channel","execution","shutdown"],"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"}