{"record":{"id":"2dc826513470016b","repo":"nautechsystems/nautilus_trader","slug":"timeout-waiting-for-account-account-id-to-be-reg-2dc826","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":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/common/execution.rs","lineNumber":89,"sourceCode":"    if 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 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#[cfg(test)]\nmod tests {\n    use std::{cell::RefCell, rc::Rc};\n\n    use nautilus_common::cache::Cache;\n    use nautilus_live::ExecutionClientCore;\n    use nautilus_model::{\n        accounts::{AccountAny, CashAccount},\n        enums::{AccountType, OmsType},\n        events::AccountState,\n        identifiers::{AccountId, TraderId},\n        types::{AccountBalance, Money},","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/a4b06ed870971b5671d12754ea138a3ab99b1dec/crates/adapters/binance/src/common/execution.rs#L71-L107","documentation":"During Binance execution client startup, await_account_registered polls the cache every 10ms until the account state fetched from Binance is registered under the expected AccountId, bailing after timeout_secs. Hitting the timeout means the account pipeline never completed - most often because the account_id in config does not match the account the API key actually returns, or the underlying account info request failed earlier.","triggerScenarios":"Startup with a config account_id that differs from the account returned for the credentials (e.g. testnet account_id with live keys); an earlier account-info REST failure (connectivity, invalid key, wrong endpoint); timeout_secs configured too small for a slow network.","commonSituations":"Copying config between live/testnet without updating account_id; egress blocked to the wrong environment's API host; degraded/slow network on first start; earlier startup errors swallowed in the log.","solutions":["Scan earlier log lines - the root cause is usually a preceding account info request failure, not the timeout itself","Verify the account_id in BinanceExecutionClientConfig matches the account the API key resolves to on that environment","Confirm network egress to the correct Binance host (fapi/api vs testnet) and key validity","Increase the startup timeout passed to await_account_registered on slow links"],"exampleFix":"# before\naccount_id = \"BINANCE-TEST-001\"   # live credentials -> never registers\n\n# after\naccount_id = \"BINANCE-001\"        # matches the live account for the key","handlingStrategy":"retry","validationCode":"// before starting the client, confirm the account is reachable for these creds\nlet info = binance_rest.get_account_info().await?; // surfaces the real error early\nanyhow::ensure!(info.account_id == config.account_id, \"config account_id {} != key's account {}\", config.account_id, info.account_id);","typeGuard":"fn account_id_matches(configured: &AccountId, fetched: &AccountId) -> bool {\n    configured == fetched\n}","tryCatchPattern":"for attempt in 1..=3 {\n    match await_account_registered(&core, account_id.clone(), timeout_secs).await {\n        Ok(()) => break,\n        Err(e) if attempt == 3 => return Err(e.context(\"account never registered - check account_id and earlier account-info errors\")),\n        Err(_) => { tokio::time::sleep(Duration::from_secs(2)).await; } // brief backoff, re-check prerequisites\n    }\n}","preventionTips":["Validate account_id against a live account info call before spawning the execution client","Surface (never swallow) account-info fetch errors at startup - they are the usual root cause","Give startup generous timeouts on first boot / cold networks, and alert on retries"],"tags":["binance","startup","account-registration","timeout","cache"],"backgroundTag":"startup-timeout","analyzedSha":"a4b06ed870971b5671d12754ea138a3ab99b1dec","analyzedAt":"2026-08-16T22:54:50.089Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}