{"record":{"id":"a38841b0d6309173","repo":"nautechsystems/nautilus_trader","slug":"execution-algorithm-restore-actor-id-not-found-w","errorCode":null,"errorMessage":"Execution algorithm {restore_actor_id} not found while restoring subscriptions","messagePattern":"Execution algorithm (.+?) not found while restoring subscriptions","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/system/src/trader.rs","lineNumber":763,"sourceCode":"        }\n\n        let component_id = exec_algorithm.component_id();\n        let clock = self.create_component_clock(component_id);\n\n        exec_algorithm.register(self.trader_id, clock, self.cache.clone())?;\n        exec_algorithm\n            .exec_algorithm_core_mut()\n            .set_portfolio(self.portfolio.clone());\n\n        register_component_actor(exec_algorithm);\n\n        // Register the {id}.execute endpoint so the order manager can\n        // route TradingCommands to this algorithm via msgbus::send_any\n        let actor_id = exec_algorithm_id.inner();\n        let restore_actor_id = actor_id;\n        let restore_fn: ExecutionAlgorithmSubscriptionFn = Box::new(move || {\n            let Some(mut algo) = try_get_actor_unchecked::<T>(&restore_actor_id) else {\n                anyhow::bail!(\n                    \"Execution algorithm {restore_actor_id} not found while restoring subscriptions\"\n                );\n            };\n\n            let mut strategy_ids = {\n                let cache = algo.exec_algorithm_core_mut().cache_ref();\n                cache\n                    .orders_for_exec_algorithm(&exec_algorithm_id, None, None, None, None, None)\n                    .into_iter()\n                    .filter(|order| {\n                        !order.is_closed() && order.exec_algorithm_id() == Some(exec_algorithm_id)\n                    })\n                    .map(|order| order.strategy_id())\n                    .collect::<Vec<_>>()\n            };\n            strategy_ids.sort_unstable();\n            strategy_ids.dedup();\n","sourceCodeStart":745,"sourceCodeEnd":781,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/system/src/trader.rs#L745-L781","documentation":"The subscription-restore closure registered by add_exec_algorithm looks the algorithm up by actor id via try_get_actor_unchecked when it needs to restore cached strategy subscriptions. If the actor is not resolvable in the registry at that moment, it fails with this message. This indicates the algorithm was unregistered or the lookup id does not match any live actor.","triggerScenarios":"The restore_fn runs (typically during trader start/restart when restoring strategy subscriptions) while try_get_actor_unchecked::<T>(&actor_id) returns None — the algorithm was removed, never registered under that id, or the registry was cleared.","commonSituations":"Stopping and restarting a trader where the exec algorithm was disposed in between; a mismatch between the registered component_id and the id used for actor lookup; hot-reload code that tears down actors without unregistering the restore hook.","solutions":["Ensure the exec algorithm remains registered/live for the whole trader lifecycle; do not dispose it while the trader can restart.","Verify the component_id used at registration matches the actor id stored in the registry.","Re-register the exec algorithm (add_exec_algorithm) after any teardown so its restore hook references a live actor."],"exampleFix":"// before\ntrader.stop();\ndispose_exec_algorithm(algo);\ntrader.start()?; // restore_fn can't find actor\n\n// after\ntrader.stop();\ntrader.add_exec_algorithm(algo)?; // re-register before restart\ntrader.start()?;","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if let Err(e) = trader.start() {\n    if e.to_string().contains(\"not found while restoring subscriptions\") {\n        trader.add_exec_algorithm(algo)?; // re-register then retry\n        trader.start()?;\n    } else { return Err(e); }\n}","preventionTips":["Never dispose an exec algorithm while its trader may restart","Keep component_id and registry actor id consistent","Re-register algorithms after any teardown before restarting the trader"],"tags":["rust","actor-lookup","exec-algorithm","restore"],"backgroundTag":"entity-not-found","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"}