{"record":{"id":"f276e5985687ec2d","repo":"nautechsystems/nautilus_trader","slug":"timeout-waiting-for-account-account-id-to-be-reg-f276e5","errorCode":null,"errorMessage":"Timeout waiting for account {account_id} to be registered after {timeout_secs}s","messagePattern":"Timeout waiting for account (.+?) to be registered after (.+?)s","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/derive/src/execution.rs","lineNumber":401,"sourceCode":"        if self.core.cache().account(&account_id).is_some() {\n            log::info!(\"Account {account_id} registered\");\n            return Ok(());\n        }\n\n        let start = Instant::now();\n        let timeout = Duration::from_secs_f64(timeout_secs);\n        let interval = Duration::from_millis(10);\n\n        loop {\n            tokio::time::sleep(interval).await;\n\n            if self.core.cache().account(&account_id).is_some() {\n                log::info!(\"Account {account_id} registered\");\n                return Ok(());\n            }\n\n            if start.elapsed() >= timeout {\n                anyhow::bail!(\n                    \"Timeout waiting for account {account_id} to be registered after {timeout_secs}s\"\n                );\n            }\n        }\n    }\n\n    /// Reverses the partial state `connect()` set up before the failing step:\n    /// cancels the shared cancellation token, aborts the WS dispatch task,\n    /// and closes the WS client. Used when initial account state cannot be\n    /// loaded so that the next `connect()` call starts from a clean slate.\n    async fn teardown_partial_connect(&mut self) -> anyhow::Result<()> {\n        self.cancellation_token.cancel();\n        self.abort_session_tasks();\n        self.abort_pending_tasks();\n\n        if let Err(e) = self.ws_client.disconnect().await {\n            self.shutdown_errors\n                .push(format!(\"Derive WebSocket shutdown failed: {e}\"));","sourceCodeStart":383,"sourceCodeEnd":419,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/derive/src/execution.rs#L383-L419","documentation":"The Derive exec client's await_account_registered polls the cache for the account state after connecting, and bails if the account is not registered within timeout_secs. It indicates the WS/HTTP auth or account-state handshake never produced a registered AccountState. This is a connect-time failure, so the client cannot execute.","triggerScenarios":"Calling connect() on DeriveExecClient when the account never appears in the cache within the configured timeout — e.g. WS auth failed, subscription to account state silently stalled, or the timeout is set too low for a slow network.","commonSituations":"Wrong or expired Derive API credentials so no account state ever arrives; very short account_registered_timeout_secs in a slow/remote environment; WS connected but account channel subscription failing silently.","solutions":["Verify Derive API credentials (wallet address and private key) are correct and authorized","Increase the account-registration timeout in the exec client config","Check logs for WS auth/subscription errors immediately preceding the timeout","Confirm network/proxy connectivity to Derive WS endpoints and retry"],"exampleFix":"// before\nDeriveExecClientConfig { account_registered_timeout_secs: 2, .. }\n// after\nDeriveExecClientConfig { account_registered_timeout_secs: 30, .. }","handlingStrategy":"try-catch","validationCode":"// pre-check credentials present before connect\nif config.private_key.is_empty() || config.wallet_address.is_empty() {\n    return Err(\"Derive credentials missing\".into());\n}","typeGuard":null,"tryCatchPattern":"match client.connect().await {\n    Err(e) if e.to_string().contains(\"Timeout waiting for account\") => {\n        log::error!(\"Derive account never registered; check creds/WS auth: {e}\");\n        // retry with larger timeout\n    }\n    other => other?,\n}","preventionTips":["Validate Derive API credentials before connecting","Set account_registered_timeout_secs generously (e.g. 30s+)","Monitor WS auth/subscription logs during startup","Alert on connect latency so slow environments are caught early"],"tags":["rust","timeout","account-registration","websocket"],"backgroundTag":"request-timeout","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"}