{"record":{"id":"88010dff05141b42","repo":"nautechsystems/nautilus_trader","slug":"failed-to-start-tardis-task-generation-e","errorCode":null,"errorMessage":"Failed to start Tardis task generation: {e}","messagePattern":"Failed to start Tardis task generation: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/tardis/src/data.rs","lineNumber":521,"sourceCode":"    }\n\n    async fn connect(&mut self) -> anyhow::Result<()> {\n        if self.is_connected() && self.tasks.is_open() {\n            return Ok(());\n        }\n\n        if self.config.options.is_empty() && self.config.stream_options.is_empty() {\n            anyhow::bail!(\"Either replay `options` or `stream_options` must be provided\");\n        }\n\n        if !self.tasks.is_open() {\n            self.tasks\n                .finish_shutdown(Duration::from_secs(1), Duration::from_secs(2))\n                .await\n                .map_err(|e| anyhow::anyhow!(\"Failed to terminate Tardis tasks: {e}\"))?;\n            self.tasks\n                .start_generation()\n                .map_err(|e| anyhow::anyhow!(\"Failed to start Tardis task generation: {e}\"))?;\n            self.cancellation_token = self.tasks.cancellation_token();\n        }\n\n        let is_stream_mode = self.is_stream_mode();\n        let book_snapshot_output = self.config.book_snapshot_output.clone();\n        let extract_bbo_as_quotes = self.config.extract_bbo_as_quotes;\n\n        let http_client = TardisHttpClient::new(\n            self.config\n                .api_key\n                .as_ref()\n                .map(|value| value.expose_secret()),\n            None,\n            None,\n            self.config.normalize_symbols,\n            self.config\n                .proxy_url\n                .as_ref()","sourceCodeStart":503,"sourceCodeEnd":539,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/tardis/src/data.rs#L503-L539","documentation":"Raised in connect when tasks.start_generation() fails while preparing the Tardis client for a new connection. The task supervisor could not open a new task generation, so no WebSocket stream task can be registered.","triggerScenarios":"Calling connect on a task set that is closed or still mid-shutdown, so start_generation is rejected.","commonSituations":"Rapid disconnect/reconnect cycling; a previously failed finish_shutdown leaving the supervisor in a bad state; calling connect after the client was stopped permanently.","solutions":["Wait for the previous shutdown to fully complete before reconnecting.","Verify finish_shutdown succeeded (error 3693 not raised) in the same connect path.","Serialize connect/disconnect calls; do not overlap lifecycle transitions.","Reconstruct the client if its task set is permanently closed."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if let Err(e) = client.connect().await {\n    if e.to_string().contains(\"Failed to start Tardis task generation\") {\n        // supervisor is closed: recreate the client rather than retrying\n        client = TardisDataClient::new(config)?;\n        client.connect().await?;\n    } else { return Err(e); }\n}","preventionTips":["Treat connect after a permanent stop as a bug; create a fresh client instead.","Serialize lifecycle transitions; never overlap shutdown with connect.","Check for earlier shutdown errors (3693) that leave the supervisor wedged."],"tags":["task-management","lifecycle","websocket"],"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"}