{"record":{"id":"e652a87427ed3c16","repo":"nautechsystems/nautilus_trader","slug":"failed-to-send-account-state-e","errorCode":null,"errorMessage":"Failed to send account state: {e}","messagePattern":"Failed to send account state: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/live/src/execution/emitter.rs","lineNumber":502,"sourceCode":"    pub fn send_account_state(&self, state: AccountState) {\n        if let Err(e) = self.try_send_account_state(state) {\n            log::warn!(\"{e}\");\n        }\n    }\n\n    /// Emits an account state 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_account_state(&self, state: AccountState) -> anyhow::Result<()> {\n        let sender = self.sender.load();\n        let sender = sender\n            .as_ref()\n            .ok_or_else(|| anyhow::anyhow!(\"Cannot send account state: sender not initialized\"))?;\n        sender\n            .send(ExecutionEvent::Account(state))\n            .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\")","sourceCodeStart":484,"sourceCodeEnd":520,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/live/src/execution/emitter.rs#L484-L520","documentation":"try_send_account_state found an initialized sender but the channel send failed because the receiver has been closed/dropped. The underlying channel error is embedded in the message. It means the execution event consumer is gone when an account state update is delivered.","triggerScenarios":"Sending an account state after the execution engine (channel receiver) was stopped — node shutdown, engine restart, or a crashed consumer task closing the channel.","commonSituations":"Periodic account-state reconciliation timers firing after shutdown started; reconnect recovery re-emitting account state while the engine task is being replaced.","solutions":["Stop account-state emissions once shutdown has begun.","Retry the emission after reconnect when a fresh receiver exists.","Treat as non-fatal during teardown and log at warn level.","Read the wrapped channel error to confirm receiver-closed semantics."],"exampleFix":"// before\nemitter.try_send_account_state(state)?;\n// after\nif let Err(e) = emitter.try_send_account_state(state) {\n    log::warn!(\"account state not delivered (receiver closed?): {e}\");\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if let Err(e) = emitter.try_send_account_state(state) { log::warn!(\"account state undelivered: {e}\"); // re-emit after reconnect }","preventionTips":["Cancel periodic account reconciliation timers on shutdown","Re-request account state after reconnect rather than caching stale sends","Treat receiver-closed as expected during teardown and log at warn"],"tags":["rust","channel","account","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"}