{"record":{"id":"3d9994e6d66e572f","repo":"nautechsystems/nautilus_trader","slug":"failed-to-save-component-state","errorCode":null,"errorMessage":"Failed to save component state: {}","messagePattern":"Failed to save component state: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/system/src/trader.rs","lineNumber":1661,"sourceCode":"                Err(e) => errors.push(format!(\"actor {actor_id} callback: {e:#}\")),\n            }\n        }\n\n        for (strategy_id, callbacks) in strategy_callbacks {\n            match (callbacks.save)(strategy_id.inner()) {\n                Ok(state) => {\n                    if let Err(e) = cache.borrow().update_strategy_state(&strategy_id, &state) {\n                        errors.push(format!(\"strategy {strategy_id} persistence: {e:#}\"));\n                    }\n                }\n                Err(e) => errors.push(format!(\"strategy {strategy_id} callback: {e:#}\")),\n            }\n        }\n\n        if errors.is_empty() {\n            Ok(())\n        } else {\n            anyhow::bail!(\"Failed to save component state: {}\", errors.join(\"; \"))\n        }\n    }\n\n    fn actor_state_callbacks(&self) -> anyhow::Result<Vec<(ActorId, ComponentStateCallbacks)>> {\n        self.actor_ids\n            .iter()\n            .map(|actor_id| {\n                self.actor_state_callbacks\n                    .get(actor_id)\n                    .copied()\n                    .map(|callbacks| (*actor_id, callbacks))\n                    .ok_or_else(|| anyhow::anyhow!(\"Actor {actor_id} state callback not found\"))\n            })\n            .collect()\n    }\n\n    fn strategy_state_callbacks(\n        &self,","sourceCodeStart":1643,"sourceCodeEnd":1679,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/system/src/trader.rs#L1643-L1679","documentation":"Trader::save_state aggregates per-component state persistence errors; if any component failed to save its state it joins the messages and bails. The whole save is reported as failed even if some components saved successfully, because a partial snapshot would be inconsistent.","triggerScenarios":"Calling trader.save_state() (e.g. on stop or periodic checkpoint) when one or more strategies/actors' state callbacks return errors, such as serialization failure or an underlying store write failing.","commonSituations":"Persistent state backend (Redis/file) unavailable or misconfigured; a strategy's save hook panics/errors due to invalid internal state; disk full or permission issues on state file.","solutions":["Read the joined message to identify which component(s) failed and fix the underlying cause for each","Verify the state persistence backend is reachable and writable before calling save_state","Save components individually to isolate which strategy/actor is failing","Retry save_state after the backend recovers, since it aggregates transient errors"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if let Err(e) = trader.save_state() { log::error!(\"save_state failed: {e}\"); /* retry or alert */ }","preventionTips":["Verify persistence backend connectivity before save_state","Monitor which component states fail via the aggregated message"],"tags":["rust","trader","persistence"],"backgroundTag":"file-write-failed","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"}