{"record":{"id":"11a6c3bf184a4b35","repo":"nautechsystems/nautilus_trader","slug":"failed-to-receive-logging-sync-acknowledgement-e","errorCode":null,"errorMessage":"failed to receive logging sync acknowledgement: {e}","messagePattern":"failed to receive logging sync acknowledgement: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/common/src/logging/logger.rs","lineNumber":1319,"sourceCode":"        }\n\n        let Some(tx) = LOGGER_TX.get() else {\n            anyhow::bail!(\"Logging is running without a published sender\");\n        };\n\n        sync_sender_to_disk(tx)\n    }\n}\n\n#[cfg(not(all(feature = \"simulation\", madsim)))]\nfn sync_sender_to_disk(tx: &std::sync::mpsc::Sender<LogEvent>) -> anyhow::Result<()> {\n    let (done_tx, done_rx) = std::sync::mpsc::channel();\n    tx.send(LogEvent::Sync(done_tx))\n        .map_err(|e| anyhow::anyhow!(\"failed to request logging sync: {e}\"))?;\n\n    done_rx\n        .recv()\n        .map_err(|e| anyhow::anyhow!(\"failed to receive logging sync acknowledgement: {e}\"))?\n}\n\n/// Logs a message with the given level, color, and component.\npub fn log<T: AsRef<str>>(level: LogLevel, color: LogColor, component: Ustr, message: T) {\n    let color = Value::from(color as u8);\n\n    match level {\n        LogLevel::Off => {}\n        LogLevel::Trace => {\n            log::trace!(component = component.to_value(), color = color; \"{}\", message.as_ref());\n        }\n        LogLevel::Debug => {\n            log::debug!(component = component.to_value(), color = color; \"{}\", message.as_ref());\n        }\n        LogLevel::Info => {\n            log::info!(component = component.to_value(), color = color; \"{}\", message.as_ref());\n        }\n        LogLevel::Warning => {","sourceCodeStart":1301,"sourceCodeEnd":1337,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/common/src/logging/logger.rs#L1301-L1337","documentation":"This error is raised by the logging sync helper in nautilus_common's logger. It sends a LogEvent::Sync over the logging worker channel and blocks on a one-shot acknowledgement channel; if the receiver end (done_rx) returns an error — typically because the sender was dropped, meaning the logging thread shut down or the ack was never sent — it wraps the RecvError in this anyhow error. It indicates the logging worker is no longer alive or responsive.","triggerScenarios":"Calling the logging sync function after the logging worker thread has been stopped or dropped; the worker panicked before sending the acknowledgement; the LogEvent::Sync was accepted but the worker exited without responding on done_tx.","commonSituations":"Shutting down or re-initializing the logging system while another thread still tries to flush/sync logs; a panic inside the logging worker; calling sync during process teardown when the channel endpoints were already dropped.","solutions":["Ensure the logging worker thread is running and has not been shut down before calling the logging sync function.","Check for panics in the logging worker that would drop done_tx without sending an acknowledgement.","Re-initialize the logging system (recreate the logger/worker) if it was torn down, then retry the sync.","Guard teardown ordering so no component calls log sync after the logging system is dropped."],"exampleFix":"// before: syncing after teardown\nlogging_shutdown();\nlogging_sync()?; // fails: receiver dropped\n// after\nlogging_sync()?;\nlogging_shutdown();","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match logging_sync() {\n    Ok(()) => {},\n    Err(e) if e.to_string().contains(\"failed to receive logging sync acknowledgement\") => {\n        // logging worker is down; re-init or skip flush during teardown\n        eprintln!(\"logging worker unavailable: {e}\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Keep the logging worker alive for the lifetime of all threads that log.","Establish a shutdown ordering: flush/sync logs before dropping the logging system.","Monitor the worker thread for panics and restart it if it dies.","Make sync calls idempotent/no-op when the logger is already shut down."],"tags":["rust","logging","channel","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"}