{"record":{"id":"0f441211f53d4708","repo":"nautechsystems/nautilus_trader","slug":"failed-to-start-lighter-data-task-generation-e","errorCode":null,"errorMessage":"Failed to start Lighter data task generation: {e}","messagePattern":"Failed to start Lighter data task generation: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/lighter/src/data/mod.rs","lineNumber":984,"sourceCode":"        if self.is_connected()\n            && self.tasks.is_open()\n            && self.ws_disconnect_handle.is_none()\n            && self.ws_handler_retained.is_empty()\n        {\n            return Ok(());\n        }\n\n        if !self.tasks.is_open()\n            || !self.tasks.is_empty()\n            || self.ws_disconnect_handle.is_some()\n            || !self.ws_handler_retained.is_empty()\n        {\n            self.teardown_partial_connect().await?;\n        }\n\n        if !self.tasks.is_open() {\n            self.tasks.start_generation().map_err(|e| {\n                anyhow::anyhow!(\"Failed to start Lighter data task generation: {e}\")\n            })?;\n            self.cancellation_token = self.tasks.cancellation_token();\n        }\n\n        let ws_client = self.ws_client.clone();\n        let setup_guard = TaskGroupGuard::new(&[&self.tasks], move || {\n            ws_client.begin_shutdown();\n        });\n\n        let instruments = self\n            .bootstrap_instruments()\n            .await\n            .context(\"failed to bootstrap Lighter instruments\")?;\n\n        for instrument in instruments {\n            if let Err(e) = self.data_sender.send(DataEvent::Instrument(instrument)) {\n                log::warn!(\"Failed to send instrument: {e}\");\n            }","sourceCodeStart":966,"sourceCodeEnd":1002,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/lighter/src/data/mod.rs#L966-L1002","documentation":"The Lighter data client failed while starting its background WebSocket data task generation during connect(). Any error returned by `tasks.start_generation()` (typically an internal spawn or channel setup failure) is wrapped in this message. It is thrown to abort a partially-completed connect and signals the client could not begin producing market data.","triggerScenarios":"Calling connect() on LighterDataClient when the internal task group's start_generation() fails — e.g. a required runtime handle is missing or the task group was already torn down after a prior partial connect failure (note the preceding teardown_partial_connect() call).","commonSituations":"Reconnecting after a failed connect in the same client instance; running in a runtime that is shutting down; a bug or incompatibility in the task-group infrastructure.","solutions":["Read the wrapped inner error ({e}) to identify the underlying start_generation failure.","Construct a fresh LighterDataClient instead of reusing one after a failed connect.","Ensure the async runtime is healthy and not shutting down when connect() is called.","Update the adapter version in case of a known task-generation bug."],"exampleFix":"// before\nlet client = build_client();\nclient.connect().await?; // may fail after prior partial connect\n// after\nlet client = build_client(); // rebuild a fresh client on retry\nclient.connect().await?;","handlingStrategy":"try-catch","validationCode":"// Rust: check task group state before connect\nassert!(!client_is_torn_down, \"rebuild client instead of reusing after failed connect\");","typeGuard":null,"tryCatchPattern":"match client.connect().await {\n    Err(e) if e.to_string().contains(\"Failed to start Lighter data task generation\") => {\n        // rebuild a fresh client and retry once\n    }\n    r => r?,\n}","preventionTips":["Rebuild data clients instead of reconnecting a failed instance.","Keep the async runtime alive while connecting clients.","Keep the adapter updated for task-group fixes."],"tags":["websocket","task-spawn","connection","async-runtime"],"backgroundTag":"module-init-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"}