{"record":{"id":"1fae052c05c1b142","repo":"nautechsystems/nautilus_trader","slug":"cannot-send-execution-report-sender-not-initializ","errorCode":null,"errorMessage":"Cannot send execution report: sender not initialized","messagePattern":"Cannot send execution report: sender not initialized","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/live/src/execution/emitter.rs","lineNumber":520,"sourceCode":"            .map_err(|e| anyhow::anyhow!(\"Failed to send account state: {e}\"))\n    }\n\n    /// Emits an execution report.\n    pub fn send_execution_report(&self, report: ExecutionReport) {\n        if let Err(e) = self.try_send_execution_report(report) {\n            log::warn!(\"{e}\");\n        }\n    }\n\n    /// Emits an execution report and returns any channel error to the caller.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the sender is not initialized or the receiving channel is closed.\n    pub fn try_send_execution_report(&self, report: ExecutionReport) -> anyhow::Result<()> {\n        let sender = self.sender.load();\n        let sender = sender.as_ref().ok_or_else(|| {\n            anyhow::anyhow!(\"Cannot send execution report: sender not initialized\")\n        })?;\n        sender\n            .send(ExecutionEvent::Report(report))\n            .map_err(|e| anyhow::anyhow!(\"Failed to send execution report: {e}\"))\n    }\n\n    /// Emits an order status report.\n    pub fn send_order_status_report(&self, report: OrderStatusReport) {\n        self.send_execution_report(ExecutionReport::Order(Box::new(report)));\n    }\n\n    /// Emits a fill report.\n    pub fn send_fill_report(&self, report: FillReport) {\n        self.send_execution_report(ExecutionReport::Fill(Box::new(report)));\n    }\n\n    /// Emits an order status report bundled with the fills that produced it.\n    pub fn send_order_with_fills(&self, report: OrderStatusReport, fills: Vec<FillReport>) {","sourceCodeStart":502,"sourceCodeEnd":538,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/live/src/execution/emitter.rs#L502-L538","documentation":"Raised by try_send_execution_report when the emitter's sender slot is still None: an ExecutionReport (order status, fills, etc.) cannot be routed because the execution event channel was never wired. This is a lifecycle/ordering violation in the live execution pipeline.","triggerScenarios":"Calling try_send_execution_report (directly or via send_execution_report, send_order_status_report, etc., or commit_post_reconnect_mass_status) before the emitter is initialized.","commonSituations":"Adapters producing execution reports from venue WebSocket messages that arrive before engine startup completes; mass-status reconciliation after reconnect racing the emitter init; unit/custom integration harnesses forgetting to start the emitter.","solutions":["Complete the emitter/engine initialization before processing any venue messages.","Buffer incoming reports until the emitter is ready, then flush in order.","Verify adapter message handlers are only registered/active after the engine start sequence.","If it happens in a running node, this indicates an internal bug — capture a repro and report it."],"exampleFix":"// before\nemitter.send_order_status_report(report);\n// after\nif emitter.is_initialized() {\n    emitter.send_order_status_report(report);\n} else {\n    pending_reports.push(report); // flush after init\n}","handlingStrategy":"validation","validationCode":"if !emitter.is_initialized() { pending_reports.push(report); return; }","typeGuard":"fn emitter_ready(emitter: &ExecutionEmitter) -> bool { emitter.is_initialized() }","tryCatchPattern":"if let Err(e) = emitter.try_send_execution_report(report) { log::error!(\"execution report send failed: {e}\"); }","preventionTips":["Only subscribe adapter message handlers after engine startup","Buffer early venue reports and flush once initialized","Reproduce startup races with integration tests"],"tags":["rust","lifecycle","execution-report","channel"],"backgroundTag":"invalid-state-transition","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"}