{"record":{"id":"521529ef17f61af9","repo":"nautechsystems/nautilus_trader","slug":"failed-to-start-coinbase-poll-generation-e","errorCode":null,"errorMessage":"Failed to start Coinbase poll generation: {e}","messagePattern":"Failed to start Coinbase poll generation: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/coinbase/src/data/poll.rs","lineNumber":144,"sourceCode":"                entry.cancel.cancel();\n                // Replace the now-cancelled token so a later `resume()` can\n                // spawn a fresh task that listens on a live token.\n                entry.cancel = CancellationToken::new();\n            }\n        }\n\n        self.tasks.begin_shutdown();\n    }\n\n    pub(crate) async fn prepare(&self) -> anyhow::Result<()> {\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 finish Coinbase poll tasks: {e}\"))?;\n            self.tasks\n                .start_generation()\n                .map_err(|e| anyhow::anyhow!(\"Failed to start Coinbase poll generation: {e}\"))?;\n        }\n        Ok(())\n    }\n\n    pub(crate) async fn finish_shutdown(&self) -> anyhow::Result<()> {\n        self.tasks\n            .finish_shutdown(Duration::from_secs(1), Duration::from_secs(2))\n            .await\n            .map_err(|e| anyhow::anyhow!(\"Failed to finish Coinbase poll tasks: {e}\"))?;\n        Ok(())\n    }\n\n    /// Spawns polling tasks for every entry with at least one active flag.\n    /// Called from `connect()` so subscriptions made before a\n    /// `disconnect()` remain live after the client reconnects: the data\n    /// engine suppresses duplicate subscribe commands, so the caller does\n    /// not re-issue them.\n    pub(crate) fn resume(&self) {","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/coinbase/src/data/poll.rs#L126-L162","documentation":"After finishing the previous shutdown in `prepare`, the adapter calls `start_generation` to open a new generation of poll tasks. Failure there (task-set state machine refused to start) is wrapped in this error.","triggerScenarios":"connect/prepare invoked when the task set's internal state forbids starting a new generation — e.g. shutdown not fully completed despite finish_shutdown returning Ok, or concurrent start_generation calls.","commonSituations":"Concurrent connect() calls from different tasks; reconnecting immediately after disconnect when generation counters are out of sync.","solutions":["Ensure connect is not called concurrently (serialize with a mutex or single task)","Verify the preceding finish_shutdown fully completed before retrying","Recreate the client instance if its task-set state is wedged","Check logs for the inner `{e}` from start_generation"],"exampleFix":"// before\nfor sym in symbols {\n    tokio::spawn(client.connect()); // concurrent connects\n}\n// after\nclient.connect().await?; // single serialized connect","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match client.prepare().await {\n    Err(e) if e.to_string().contains(\"Failed to start Coinbase poll generation\") => {\n        // state race: recreate client\n        client = recreate_client(config).await?;\n    }\n    other => other?,\n}","preventionTips":["Never call connect/prepare from multiple tasks concurrently","Wrap reconnection in a single supervisor task","Treat a wedged task set as fatal and rebuild the client"],"tags":["rust","async","tasks","lifecycle","coinbase"],"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-14T00:17:10.932Z"}